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()])); }
@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()); }
.isEqualToIgnoringGivenFields(environment, "environmentName", "cluster", "environmentType"); assertThat(response.getEnvironment()) .hasFieldOrPropertyWithValue("cluster", id.getCluster())
.isEqualToIgnoringGivenFields(environment, "environmentName", "cluster", "environmentType"); assertThat(response.getEnvironment()) .hasFieldOrPropertyWithValue("cluster", id.getCluster())
.isEqualToIgnoringGivenFields( localErrorEventMethod.typeModel.fields.get(0), "representedObject");
public static <T> void checkSerializationComparingFieldByField(@Nullable T object, @NotNull Serializer<T> serializer, @NotNull String... fieldsToIgnore) throws IOException, ClassNotFoundException { final T deserializedObject = performRoundTripThroughSerialization(object, serializer); if (object == null) { assertThat(deserializedObject).isNull(); } else { InternalSerialUtils.checkIsNotNull(deserializedObject); assertThat(deserializedObject.getClass()).isEqualTo(object.getClass()); assertThat(deserializedObject).isEqualToIgnoringGivenFields(object, fieldsToIgnore); } }
@Test public void createApiClient(){ final String projectKey = getSphereClientConfig().getProjectKey(); final ApiClientCreateCommand createCommand =ApiClientCreateCommand.of(ApiClientDraftBuilder.of(ApiClientFixtures.GENERATED_CLIENT_NAME, projectKey, MANAGE_MY_ORDERS, MANAGE_API_CLIENTS).deleteDaysAfterCreation(1).build()); final ApiClient res = client().executeBlocking(createCommand); assertThat(res).isNotNull(); final String expectedScope = asList(MANAGE_MY_ORDERS, MANAGE_API_CLIENTS).stream().map(SphereScope::toScopeString).map(s -> s+":"+projectKey).collect(Collectors.joining(" ")); assertThat(res.getScope()).isEqualTo(expectedScope); assertThat(res.getDeleteAt()).isNotNull(); final ApiClient deletedRes =client().executeBlocking(ApiClientDeleteCommand.of(res)); assertThat(deletedRes).isEqualToIgnoringGivenFields(res,"secret"); }
@Test public void testGetRosterState() { RosterState rosterState = new RosterState(null, 7, LocalDate.of(2000, 1, 1), 7, 7, 0, 7, LocalDate.of(1999, 12, 26), ZoneOffset.UTC); rosterState.setTenant(new Tenant("test")); Tenant tenant = createTestTenant(rosterState); rosterState.setTenant(tenant); rosterState.setTenantId(tenant.getId()); RosterState receivedRosterState = rosterRestService.getRosterState(TENANT_ID); assertThat(receivedRosterState).isEqualToIgnoringGivenFields(rosterState, IGNORED_FIELDS); }
private void assertCorrectInitializeResult(InitializeResult result) { CompletionOptions comp = new CompletionOptions(false, ImmutableList.of(".")); ServerCapabilities capabilities = new ServerCapabilities(); capabilities.setDocumentSymbolProvider(true); capabilities.setWorkspaceSymbolProvider(true); capabilities.setReferencesProvider(true); capabilities.setCompletionProvider(comp); capabilities.setDefinitionProvider(true); capabilities.setTextDocumentSync(TextDocumentSyncKind.Incremental); assertThat(capabilities).isEqualToIgnoringGivenFields(result.getCapabilities(), "textDocumentSync"); }
@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(); } }
assertThat(retrievedSpot).isNotNull().isEqualToIgnoringGivenFields(testUpdateSpot, "version");
@Test public void testQueryModel(){ final String projectKey = getSphereClientConfig().getProjectKey(); final ApiClientCreateCommand createCommand =ApiClientCreateCommand.of(ApiClientDraftBuilder.of(ApiClientFixtures.GENERATED_CLIENT_NAME, projectKey, MANAGE_MY_ORDERS, MANAGE_API_CLIENTS).deleteDaysAfterCreation(1).build()); final ApiClient res = client().executeBlocking(createCommand);assertThat(res).isNotNull(); final PagedQueryResult<ApiClient> result = client().executeBlocking(ApiClientQuery.of() .plusPredicates(m -> m.id().is(res.getId())) ); assertEventually(() ->{ assertThat(result.getResults()).hasSize(1); }); assertThat(result.getResults().get(0)).isEqualToIgnoringGivenFields(res,"secret"); final ApiClient deletedRes =client().executeBlocking(ApiClientDeleteCommand.of(res)); assertThat(deletedRes).isEqualToIgnoringGivenFields(res,"secret"); } }
assertThat(retrievedEmployee).isNotNull().isEqualToIgnoringGivenFields(testUpdateEmployee, "version");
@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(); }
assertThat(origDepDesc).isEqualToIgnoringGivenFields(copyDepDesc, "mappedRoles");
assertThat(origDepDesc).isEqualToIgnoringGivenFields(copyDepDesc, "mappedRoles");
@Test public void shouldCreateTheRelationshipAndTheNewCurrentStateBetweenEntities() throws Throwable { try (Driver driver = GraphDatabase .driver(neo4j.boltURI(), Config.build().withEncryption().toConfig()); Session session = driver.session()) { // Given Node entityA = initEntity(session); Node entityB = initEntity(session); String testType = "testType"; // When String query = "MATCH (a:Entity), (b:Entity) WHERE id(a) = %d AND id(b) = %d WITH a, b CALL graph.versioner.relationship.create(a, b, '%s') YIELD relationship RETURN relationship"; Relationship relationship = session.run(String.format(query, entityA.id(), entityB.id(), testType)).single().get("relationship").asRelationship(); // Then String querySourceCurrent = "MATCH (e:Entity)-[:CURRENT]-(s:State) WHERE id(e) = %d RETURN s"; String queryDestinationR = "MATCH (e:Entity)<-[:FOR]-(r:R) WHERE id(e) = %d RETURN r"; Node sourceCurrent = session.run(String.format(querySourceCurrent, entityA.id())).single().get("s").asNode(); Node destinationR = session.run(String.format(queryDestinationR, entityB.id())).single().get("r").asNode(); Relationship expected = new InternalRelationship(0L, sourceCurrent.id(), destinationR.id(), testType); assertThat(relationship).isEqualToIgnoringGivenFields(expected, "id"); } }
builder -> builder.shippingInfo(shippingInfo), order -> assertThat(order.getShippingInfo()). isEqualToIgnoringGivenFields(shippingInfo, "taxedPrice", "shippingMethodState") ); });