@Test public void deprecatedOperationWithToRemoveInPriorToSinceVersion() { when(operationModel.isDeprecated()).thenReturn(true); when(operationModel.getDeprecationModel()) .thenReturn(of(new ImmutableDeprecationModel("This operation is deprecated", "2.2.0", "2.0.0"))); ProblemsReporter problemsReporter = new ProblemsReporter(extensionModel); validator.validate(extensionModel, problemsReporter); assertTrue(problemsReporter.hasErrors()); assertThat(problemsReporter.getErrors().get(0).getMessage(), is("The versions chosen for the deprecation of the operation named extensionOperation are invalid, `since`(2.2.0) version must be prior to the `removeTo`(2.0.0) version.")); }
@Test public void deprecatedOperationWithInvalidVersion() { when(operationModel.isDeprecated()).thenReturn(true); when(operationModel.getDeprecationModel()) .thenReturn(of(new ImmutableDeprecationModel("This operation is deprecated", "2.hola", null))); ProblemsReporter problemsReporter = new ProblemsReporter(extensionModel); validator.validate(extensionModel, problemsReporter); assertTrue(problemsReporter.hasErrors()); assertThat(problemsReporter.getErrors().get(0).getMessage(), is("The operation named extensionOperation was deprecated with an invalid 'since' version : '2.hola' . This version must follow the semver convention")); }
@Test public void deprecatedOperationWithValidVersions() { when(operationModel.isDeprecated()).thenReturn(true); when(operationModel.getDeprecationModel()) .thenReturn(of(new ImmutableDeprecationModel("This operation is deprecated", "2.2.3", "3.0.0"))); ProblemsReporter problemsReporter = new ProblemsReporter(extensionModel); validator.validate(extensionModel, problemsReporter); assertFalse(problemsReporter.hasErrors()); }