本文整理了Java中org.assertj.core.api.ListAssert.usingElementComparatorIgnoringFields()
方法的一些代码示例,展示了ListAssert.usingElementComparatorIgnoringFields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAssert.usingElementComparatorIgnoringFields()
方法的具体详情如下:
包路径:org.assertj.core.api.ListAssert
类名称:ListAssert
方法名:usingElementComparatorIgnoringFields
暂无
代码示例来源:origin: azkaban/azkaban
private void assertTriggerInstancesEqual(final TriggerInstance actual,
final TriggerInstance expected, final boolean ignoreFlowTrigger) {
if (!ignoreFlowTrigger) {
if (actual.getFlowTrigger() != null && expected.getFlowTrigger() != null) {
assertThat(actual.getFlowTrigger().toString())
.isEqualToIgnoringWhitespace(expected.getFlowTrigger().toString());
} else {
assertThat(actual.getFlowTrigger()).isNull();
assertThat(expected.getFlowTrigger()).isNull();
}
}
assertThat(actual).isEqualToIgnoringGivenFields(expected, "depInstances", "flowTrigger");
assertThat(actual.getDepInstances())
.usingComparatorForElementFieldsWithType((d1, d2) -> {
if (d1 == null && d2 == null) {
return 0;
} else if (d1 != null && d2 != null && d1.getTime() == d2.getTime()) {
return 0;
} else {
return -1;
}
}, Date.class)
.usingElementComparatorIgnoringFields("triggerInstance", "context")
.containsExactlyInAnyOrder(expected.getDepInstances()
.toArray(new DependencyInstance[expected.getDepInstances().size()]));
}
代码示例来源:origin: azkaban/azkaban
@Test
public void testUploadTriggerInstance() {
final TriggerInstance expectedTriggerInst = this.createTriggerInstance(this.flowTrigger, this
.flow_id, this.flow_version, this.submitUser, this.project, System.currentTimeMillis());
this.triggerInstLoader.uploadTriggerInstance(expectedTriggerInst);
final TriggerInstance actualTriggerInst = this.triggerInstLoader
.getTriggerInstanceById(expectedTriggerInst.getId());
assertThat(expectedTriggerInst.getFlowTrigger().toString())
.isEqualToIgnoringWhitespace(actualTriggerInst.getFlowTrigger().toString());
assertThat(expectedTriggerInst).isEqualToIgnoringGivenFields(actualTriggerInst,
"depInstances", "flowTrigger");
assertThat(expectedTriggerInst.getDepInstances())
.usingElementComparatorIgnoringFields("triggerInstance", "context")
.containsAll(actualTriggerInst.getDepInstances())
.hasSameSizeAs(actualTriggerInst.getDepInstances());
}
代码示例来源:origin: webanno/webanno
@Test
public void thatExportingWorks() throws Exception
{
// Export the project and import it again
ArgumentCaptor<AnnotationLayer> captor = runExportImportAndFetchEvents();
// Check that after re-importing the exported projects, they are identical to the original
assertThat(captor.getAllValues())
.usingElementComparatorIgnoringFields("id")
.containsExactlyInAnyOrderElementsOf(layers());
}
代码示例来源:origin: kiegroup/optaweb-employee-rostering
assertThat(spots).usingElementComparatorIgnoringFields(IGNORED_FIELDS).containsExactly(testAddSpot);
代码示例来源:origin: kiegroup/optaweb-employee-rostering
@Test
public void testCrudSkill() {
Skill testAddSkill = new Skill(TENANT_ID, "A");
skillRestService.addSkill(TENANT_ID, testAddSkill);
assertClientResponseOk();
List<Skill> skills = skillRestService.getSkillList(TENANT_ID);
assertClientResponseOk();
assertThat(skills).usingElementComparatorIgnoringFields(IGNORED_FIELDS).containsExactly(testAddSkill);
Skill testUpdateSkill = skills.get(0);
testUpdateSkill.setName("B");
skillRestService.updateSkill(TENANT_ID, testUpdateSkill);
Skill retrievedSkill = skillRestService.getSkill(TENANT_ID, testUpdateSkill.getId());
assertClientResponseOk();
assertThat(retrievedSkill).isNotNull().isEqualToIgnoringGivenFields(testUpdateSkill, "version");
boolean result = skillRestService.removeSkill(TENANT_ID, retrievedSkill.getId());
assertThat(result).isTrue();
assertClientResponseOk();
skills = skillRestService.getSkillList(TENANT_ID);
assertThat(skills).isEmpty();
}
}
代码示例来源:origin: kiegroup/optaweb-employee-rostering
assertThat(employees).usingElementComparatorIgnoringFields(IGNORED_FIELDS).containsExactly(testAddEmployee);
代码示例来源:origin: kiegroup/optaweb-employee-rostering
@Test
public void testCrudShiftTemplate() {
Spot spot = createSpot("spot");
Employee rotationEmployee = createEmployee("rotationEmployee");
Duration startOffset = Duration.ofDays(1);
Duration shiftDuration = Duration.ofHours(8);
ShiftTemplateView testAddShiftTemplate = createShiftTemplate(spot, null, startOffset, shiftDuration);
rotationRestService.addShiftTemplate(TENANT_ID, testAddShiftTemplate);
assertClientResponseOk();
List<ShiftTemplateView> shiftTemplates = rotationRestService.getShiftTemplateList(TENANT_ID);
assertClientResponseOk();
assertThat(shiftTemplates)
.usingComparatorForElementFieldsWithType(Comparator.naturalOrder(), Integer.class)
.usingComparatorForElementFieldsWithType(Comparator.naturalOrder(), Long.class)
.usingComparatorForElementFieldsWithType(Comparator.naturalOrder(), Duration.class)
.usingElementComparatorIgnoringFields(IGNORED_FIELDS)
.containsExactly(testAddShiftTemplate);
ShiftTemplateView testUpdateShiftTemplate = shiftTemplates.get(0);
testUpdateShiftTemplate.setRotationEmployeeId(rotationEmployee.getId());
rotationRestService.updateShiftTemplate(TENANT_ID, testUpdateShiftTemplate);
ShiftTemplateView retrievedShiftTemplate = rotationRestService.getShiftTemplate(TENANT_ID, testUpdateShiftTemplate.getId());
assertClientResponseOk();
assertThat(retrievedShiftTemplate).isNotNull().isEqualToIgnoringGivenFields(testUpdateShiftTemplate, IGNORED_FIELDS);
boolean result = rotationRestService.removeShiftTemplate(TENANT_ID, retrievedShiftTemplate.getId());
assertThat(result).isTrue();
assertClientResponseOk();
shiftTemplates = rotationRestService.getShiftTemplateList(TENANT_ID);
assertThat(shiftTemplates).isEmpty();
}
内容来源于网络,如有侵权,请联系作者删除!