public static void verifyMinimumMigrationNumber(DbVersion underTest, int minimumMigrationNumber) { TestMigrationStepRegistry registry = new TestMigrationStepRegistry() { @Override public <T extends MigrationStep> MigrationStepRegistry add(long migrationNumber, String description, Class<T> stepClass) { super.add(migrationNumber, description, MigrationStep.class); assertThat(migrationNumber).isGreaterThanOrEqualTo(minimumMigrationNumber); return this; } }; underTest.addSteps(registry); assertThat(registry.migrationNumbers).describedAs("No migration added to registry").isNotEmpty(); assertThat(registry.migrationNumbers.stream().sorted().findFirst().get()).isEqualTo(minimumMigrationNumber); }
@Test public void serializeValue_resultJsonHasValue() throws IOException { //given categoryGraphics.setValue(new Integer[] {new Integer(1), new Integer(2)}); //when JsonNode actualObj = helper.serializeObject(categoryGraphics); //then Assertions.assertThat(actualObj.has("value")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("value"); Assertions.assertThat(arrayNode).isNotEmpty(); }
@Test public void serializeColors_resultJsonHasColors() throws IOException { //given categoryGraphics.setColor(Arrays.asList(Color.BLACK, Color.BLUE)); //when JsonNode actualObj = helper.serializeObject(categoryGraphics); //then Assertions.assertThat(actualObj.has("colors")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("colors"); Assertions.assertThat(arrayNode).isNotEmpty(); }
@Test public void serializeColorsOfHistogram_resultJsonHasColors() throws IOException { //when histogram.setColor(Arrays.asList(Color.GREEN, Color.BLUE)); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("colors")).isTrue(); Assertions.assertThat(actualObj.get("colors")).isNotEmpty(); }
@Test public void serializeDataListOfHistogram_resultJsonHasGraphicsList() throws IOException { //when histogram.setData(Arrays.asList(1, 2)); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("graphics_list")).isTrue(); Assertions.assertThat(actualObj.get("graphics_list")).isNotEmpty(); }
@Test public void serializeXOfXYGraphicsLine_resultJsonHasX() throws IOException { //when line.setX(Arrays.asList(1, 2, 3)); xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); Assertions.assertThat(actualObj.get("x")).isNotEmpty(); }
@Test public void serializeYOfXYGraphicsLine_resultJsonHasY() throws IOException { //when line.setY(Arrays.asList(1, 2, 3)); xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("y")).isTrue(); Assertions.assertThat(actualObj.get("y")).isNotEmpty(); }
@Test public void serializeXConstantBand_resultJsonHasX() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setX(Arrays.asList(1, 2, 3)); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); Assertions.assertThat(actualObj.get("x")).isNotEmpty(); }
@Test public void serializeColorsPoints_resultJsonHasColors() throws IOException { //when points.setColor(Arrays.asList(Color.GREEN, Color.BLUE)); pointsSerializer.serialize(points, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("colors")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("colors"); Assertions.assertThat(arrayNode.get(1)).isNotEmpty(); }
@Test public void serializeYConstantBand_resultJsonHasY() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setY(Arrays.asList(1, 2, 3)); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("y")).isTrue(); Assertions.assertThat(actualObj.get("y")).isNotEmpty(); }
@Test public void serializeTextsOfXYChartPlot_resultJsonHasTexts() throws IOException { //given plot.add(new Text()); //when xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("texts")).isTrue(); Assertions.assertThat(actualObj.get("texts")).isNotEmpty(); }
@Test public void realExamples() { File testFile = DuplicationsTestUtil.findFile("/java/MessageResources.java"); assertThat(chunk(testFile)).isNotEmpty(); testFile = DuplicationsTestUtil.findFile("/java/RequestUtils.java"); assertThat(chunk(testFile)).isNotEmpty(); }
@Test public void createAreaByEmptyConstructor_hasPossibleFiltersIsNotEmpty(){ //when Area area = new Area(); //when Assertions.assertThat(area.getPossibleFilters()).isNotEmpty(); }
@Test public void validateWhenJwtHasNoIssuerThenReturnsError() { Jwt jwt = new Jwt( MOCK_TOKEN, MOCK_ISSUED_AT, MOCK_EXPIRES_AT, MOCK_HEADERS, Collections.singletonMap(JwtClaimNames.AUD, "https://aud")); OAuth2TokenValidatorResult result = this.validator.validate(jwt); assertThat(result.getErrors()).isNotEmpty(); }
@Test public void validateWhenIssuerMismatchesThenReturnsError() { Jwt jwt = new Jwt( MOCK_TOKEN, MOCK_ISSUED_AT, MOCK_EXPIRES_AT, MOCK_HEADERS, Collections.singletonMap(JwtClaimNames.ISS, "https://other")); OAuth2TokenValidatorResult result = this.validator.validate(jwt); assertThat(result.getErrors()).isNotEmpty(); }
@Test public void createPointsByEmptyConstructor_hasPossibleFiltersIsNotEmpty(){ //when Points points = new Points(); //when Assertions.assertThat(points.getPossibleFilters()).isNotEmpty(); }
@Test public void createStemsByEmptyConstructor_hasPossibleFiltersIsNotEmpty(){ //when Stems stems = new Stems(); //when Assertions.assertThat(stems.getPossibleFilters()).isNotEmpty(); }
@Test public void define_xoo_hotspot_rule() { RulesDefinition.Repository repo = context.repository("xoo"); assertThat(repo).isNotNull(); assertThat(repo.name()).isEqualTo("Xoo"); assertThat(repo.language()).isEqualTo("xoo"); assertThat(repo.rules()).hasSize(19); RulesDefinition.Rule rule = repo.rule(HotspotSensor.RULE_KEY); assertThat(rule.name()).isNotEmpty(); assertThat(rule.securityStandards()) .isNotEmpty() .containsExactlyInAnyOrder("cwe:1", "cwe:123", "cwe:863", "owaspTop10:a1", "owaspTop10:a3"); }
@Test public void stdErrorHandlerWrite_addConsoleOutput() throws Exception { //given BeakerOutputHandler handler = seo.getStdErrorHandler(); //when handler.write("test"); //then Assertions.assertThat(seo.getConsoleOutput()).isNotEmpty(); }
@Test public void create_index() { IndexCreator underTest = startNewCreator(new FakeIndexDefinition()); // check that index is created with related mapping verifyFakeIndex(); // of course do not delete indices on stop underTest.stop(); assertThat(mappings()).isNotEmpty(); }