@Test public void automaticallyMigratesTimestampsAndFailsOnRestart() throws Exception { TimestampService timestampClient = createEteClientFor(TimestampService.class); TodoResource todoClient = createEteClientFor(TodoResource.class); todoClient.addTodo(TODO); softAssertions.assertThat(todoClient.getTodoList()) .as("contains one todo pre-migration") .contains(TODO); long embeddedTimestamp = timestampClient.getFreshTimestamp(); softAssertions.assertThat(embeddedTimestamp) .as("can get a timestamp before migration") .isNotNull(); upgradeAtlasClientToTimelock(); assertTimeLockGivesHigherTimestampThan(embeddedTimestamp); softAssertions.assertThat(todoClient.getTodoList()) .as("can still read todo after migration to TimeLock") .contains(TODO); todoClient.addTodo(TODO_2); softAssertions.assertThat(todoClient.getTodoList()) .as("can add a new todo using TimeLock") .contains(TODO, TODO_2); assertNoLongerExposesEmbeddedTimestampService(); downgradeAtlasClientFromTimelockWithoutMigration(); assertCanNeitherReadNorWrite(); }
private void validateList(List<String> actualList, List<String> expectedList, String message) { if (CollectionUtils.isNotEmpty(expectedList)) { softAssertions.assertThat(actualList).as(message).isNotEmpty(); if (CollectionUtils.isNotEmpty(actualList)) { softAssertions.assertThat(actualList).as(message).containsAll(expectedList); } } else { softAssertions.assertThat(actualList).as(message).isNullOrEmpty(); } }
private void validateList(List<String> actualList, List<String> expectedList, String message) { if (CollectionUtils.isNotEmpty(expectedList)) { softAssertions.assertThat(actualList).as(message).isNotEmpty(); if (CollectionUtils.isNotEmpty(actualList)) { softAssertions.assertThat(actualList).as(message).hasSameElementsAs(expectedList); } } else { softAssertions.assertThat(actualList).as(message).isNullOrEmpty(); } }
private void validateDefinitionRequiredProperties(List<String> actualRequiredProperties, List<String> expectedRequiredProperties, String definitionName) { if (CollectionUtils.isNotEmpty(expectedRequiredProperties)) { softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).isNotEmpty(); if (CollectionUtils.isNotEmpty(actualRequiredProperties)) { final Set<String> filteredExpectedProperties = filterWhitelistedPropertyNames(definitionName, new HashSet<>(expectedRequiredProperties)); softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).hasSameElementsAs(filteredExpectedProperties); } } else { softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).isNullOrEmpty(); } }
private void validateDefinitionRequiredProperties(List<String> actualRequiredProperties, List<String> expectedRequiredProperties, String definitionName) { if (CollectionUtils.isNotEmpty(expectedRequiredProperties)) { softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).isNotEmpty(); if (CollectionUtils.isNotEmpty(actualRequiredProperties)) { final Set<String> filteredExpectedProperties = filterWhitelistedPropertyNames(definitionName, new HashSet<>(expectedRequiredProperties)); softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).hasSameElementsAs(filteredExpectedProperties); } } else { softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).isNullOrEmpty(); } }
private void validateParameters(List<Parameter> actualOperationParameters, List<Parameter> expectedOperationParameters, String httpMethod, String path) { String message = String.format("Checking parameters of '%s' operation of path '%s'", httpMethod, path); if (CollectionUtils.isNotEmpty(expectedOperationParameters)) { softAssertions.assertThat(actualOperationParameters).as(message).isNotEmpty(); if (CollectionUtils.isNotEmpty(actualOperationParameters)) { softAssertions.assertThat(actualOperationParameters).as(message).hasSameSizeAs(expectedOperationParameters); softAssertions.assertThat(actualOperationParameters).as(message).usingElementComparatorOnFields("in", "name", "required").hasSameElementsAs(expectedOperationParameters); Map<String, Parameter> expectedParametersAsMap = new HashMap<>(); for (Parameter expectedParameter : expectedOperationParameters) { expectedParametersAsMap.put(expectedParameter.getName(), expectedParameter); } for (Parameter actualParameter : actualOperationParameters) { String parameterName = actualParameter.getName(); Parameter expectedParameter = expectedParametersAsMap.get(parameterName); validateParameter(actualParameter, expectedParameter, parameterName, httpMethod, path); } } } else { softAssertions.assertThat(actualOperationParameters).as(message).isNullOrEmpty(); } }
public SoftScoreAssertion hasNoReminder() { isNotNull(); softAssertions.assertThat(actual.getReminder()) .as("Reminder is empty") .isEmpty(); return this; }
private SoftScoreAssertion hasNoCombination() { isNotNull(); softAssertions.assertThat(actual.getCombination()) .as("Combination is empty") .isEmpty(); return this; }
public SoftScoreAssertion hasReminder(List<Dice> expected) { isNotNull(); softAssertions.assertThat(actual.getReminder()) .as("Has reminder") .isEqualTo(expected); return this; }
public SoftScoreAssertion hasCombination(List<Dice> expected) { isNotNull(); softAssertions.assertThat(actual.getCombination()) .as("Has combination") .isEqualTo(expected); return this; }
List<String> expectedEnums = expectedPathParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualPathParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualPathParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedQueryParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualQueryParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualQueryParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedHeaderParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualHeaderParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualHeaderParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedFormParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualFormParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualFormParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedCookieParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualCookieParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualCookieParameter.getEnum()).as(message).isNullOrEmpty();
List<String> expectedEnums = expectedPathParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualPathParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualPathParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedQueryParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualQueryParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualQueryParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedHeaderParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualHeaderParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualHeaderParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedFormParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualFormParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualFormParameter.getEnum()).as(message).isNullOrEmpty(); List<String> expectedEnums = expectedCookieParameter.getEnum(); if (CollectionUtils.isNotEmpty(expectedEnums)) { softAssertions.assertThat(actualCookieParameter.getEnum()).as(message).hasSameElementsAs(expectedEnums); } else { softAssertions.assertThat(actualCookieParameter.getEnum()).as(message).isNullOrEmpty();
private void validatePath(String pathName, Path actualPath, Path expectedPath) { if (expectedPath != null) { softAssertions.assertThat(actualPath.getOperations()).as("Checking number of operations of path '%s'", pathName).hasSameSizeAs(actualPath.getOperations()); validateOperation(actualPath.getGet(), expectedPath.getGet(), pathName, "GET"); validateOperation(actualPath.getDelete(), expectedPath.getDelete(), pathName, "DELETE"); validateOperation(actualPath.getPost(), expectedPath.getPost(), pathName, "POST"); validateOperation(actualPath.getPut(), expectedPath.getPut(), pathName, "PUT"); validateOperation(actualPath.getPatch(), expectedPath.getPatch(), pathName, "PATCH"); validateOperation(actualPath.getOptions(), expectedPath.getOptions(), pathName, "OPTIONS"); } }
@Test public void verifiesScoreSoftlyUsingRule() { Score score = Score.scoreBuilder() .withValue(11) .withCombination(dice(1, 1, 3, 4)) .withReminder(dice(6)) .build(); softAssertions.assertThat(score.getValue()) .as("Has score") .isEqualTo(8); softAssertions.assertThat(score.getCombination()) .as("Has combination") .isEqualTo(dice(1, 1, 3, 3)); softAssertions.assertThat(score.getReminder()) .as("Has reminder") .isEqualTo(dice(5)); }
@Test public void verifiesScoreSoftly() { Score score = Score.scoreBuilder() .withValue(11) .withCombination(dice(1, 1, 3, 4)) .withReminder(dice(6)) .build(); SoftAssertions softAssertions = new SoftAssertions(); softAssertions.assertThat(score.getValue()) .as("Has score") .isEqualTo(8); softAssertions.assertThat(score.getCombination()) .as("Has combination") .isEqualTo(dice(1, 1, 3, 3)); softAssertions.assertThat(score.getReminder()) .as("Has reminder") .isEqualTo(dice(5)); softAssertions.assertAll(); }