@Test public void annotatedAnnotationAtInterfaceLevelIsDetected() throws Exception { MockMethodInvocation annotatedAtInterfaceLevel = new MockMethodInvocation( new AnnotatedAnnotationAtInterfaceLevel(), ReturnVoid2.class, "doSomething", List.class); ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray( new ConfigAttribute[0]); assertThat(attrs).hasSize(1); assertThat(attrs).extracting("attribute").containsOnly("CUSTOM"); }
@Test public void annotatedAnnotationAtMethodLevelIsDetected() throws Exception { MockMethodInvocation annotatedAtMethodLevel = new MockMethodInvocation( new AnnotatedAnnotationAtMethodLevel(), ReturnVoid.class, "doSomething", List.class); ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray( new ConfigAttribute[0]); assertThat(attrs).hasSize(1); assertThat(attrs).extracting("attribute").containsOnly("CUSTOM"); }
@Test public void annotatedAnnotationAtClassLevelIsDetected() throws Exception { MockMethodInvocation annotatedAtClassLevel = new MockMethodInvocation( new AnnotatedAnnotationAtClassLevel(), ReturnVoid.class, "doSomething", List.class); ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray( new ConfigAttribute[0]); assertThat(attrs).hasSize(1); assertThat(attrs).extracting("attribute").containsOnly("CUSTOM"); }
private void assertThatComponentHasName(ComponentDto component, String expectedName) { SearchHit[] hits = es.client() .prepareSearch(INDEX_TYPE_COMPONENT) .setQuery(matchQuery(SORTABLE_ANALYZER.subField(FIELD_NAME), expectedName)) .get() .getHits() .getHits(); assertThat(hits) .extracting(SearchHit::getId) .contains(component.uuid()); } }
private void assertThatProjectHasTag(ComponentDto project, String expectedTag) { SearchRequestBuilder request = es.client() .prepareSearch(INDEX_TYPE_PROJECT_MEASURES) .setQuery(boolQuery().filter(termQuery(FIELD_TAGS, expectedTag))); assertThat(request.get().getHits().getHits()) .extracting(SearchHit::getId) .contains(project.uuid()); }
@Test public void supports_highlighting_over_multiple_lines_including_an_empty_one() { List<ScannerReport.SyntaxHighlightingRule> syntaxHighlightingList = new ArrayList<>(); addHighlighting(syntaxHighlightingList, 1, 0, 1, 7, KEYWORD); // package addHighlighting(syntaxHighlightingList, 2, 0, 4, 6, CPP_DOC); // comment over 3 lines addHighlighting(syntaxHighlightingList, 5, 0, 5, 6, KEYWORD); // public addHighlighting(syntaxHighlightingList, 5, 7, 5, 12, KEYWORD); // class HighlightingLineReader highlightingLineReader = new HighlightingLineReader(FILE, syntaxHighlightingList.iterator(), new RangeOffsetConverter()); DbFileSources.Line.Builder[] builders = new DbFileSources.Line.Builder[] { addSourceLine(highlightingLineReader, 1, "package example;"), addSourceLine(highlightingLineReader, 2, "/*"), addSourceLine(highlightingLineReader, 3, ""), addSourceLine(highlightingLineReader, 4, " foo*/"), addSourceLine(highlightingLineReader, 5, "public class One {"), addSourceLine(highlightingLineReader, 6, "}") }; assertThat(builders) .extracting("highlighting") .containsExactly( "0,7,k", "0,2,cppd", "", "0,6,cppd", "0,6,k;7,12,k", ""); }
public void testOverriddenSource() { configureByTestName(); assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "id" ); }
@Then("^the user should receive an attachment access token$") public void accessTokenResponse() throws Throwable { assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(response.getHeaders("Content-Type")).extracting(Header::toString).containsExactly("Content-Type: text/plain"); assertThat(IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8)).isNotEmpty(); }
public void testOverriddenTarget() { configureByTestName(); assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "id" ); }
@Test public void shouldFindAFromB() { // because the graph is fully connected, we should be able to save any object to fully populate the graph session.save(a1); b1 = session.load(B.class, b1.id); b2 = session.load(B.class, b2.id); b3 = session.load(B.class, b3.id); assertThat(b1.r.length).isEqualTo(2); assertThat(b2.r.length).isEqualTo(2); assertThat(b3.r.length).isEqualTo(2); assertThat(b1.r).extracting(b -> b.a).containsExactlyInAnyOrder(a1, a2); assertThat(b2.r).extracting(b -> b.a).containsExactlyInAnyOrder(a1, a3); assertThat(b3.r).extracting(b -> b.a).containsExactlyInAnyOrder(a2, a3); }
@Test public void shouldFindBFromA() { // because the graph is fully connected, we should be able to save any object to fully populate the graph session.save(b1); a1 = session.load(A.class, a1.id); a2 = session.load(A.class, a2.id); a3 = session.load(A.class, a3.id); assertThat(a1.r).extracting(x -> x.b).containsExactlyInAnyOrder(b1, b2); assertThat(a2.r).extracting(x -> x.b).containsExactlyInAnyOrder(b1, b3); assertThat(a3.r).extracting(x -> x.b).containsExactlyInAnyOrder(b2, b3); }
public void testNestedSecondLevelAutoCompleteBuilderTargetProperty() { configureByTestName(); assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "name" ); assertThat( myItems ) .extracting( LookupElementPresentation::renderElement ) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( createVariable( "name", "String" ) ); }
@Test public void shouldFindBFromA() { session.save(b1); a = session.load(A.class, a.id); assertThat(a.r.length).isEqualTo(2); assertThat(a.r).extracting(x -> x.b).containsExactlyInAnyOrder(b1, b2); }
public void testNestedSecondLevelAutoCompleteSourceProperty() { configureByTestName(); assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "name" ); assertThat( myItems ) .extracting( LookupElementPresentation::renderElement ) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( createVariable( "name", "String" ) ); }
public void testNestedSecondLevelAutoCompleteTargetProperty() { configureByTestName(); assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "name" ); assertThat( myItems ) .extracting( LookupElementPresentation::renderElement ) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( createVariable( "name", "String" ) ); }
private void assertFluentPersonDtoAutoComplete() { assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "name", "address" ); assertThat( myItems ) .extracting( LookupElementPresentation::renderElement ) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( createVariable( "name", "String" ), createVariable( "address", "String" ) ); }
@Then("^the user should receive a specified JSON content$") public void jsonResponse() throws Exception { assertThat(response.getHeaders("Content-Type")) .extracting(header -> normalizeContentType(header.getValue())) .containsExactly( normalizeContentType(org.apache.http.entity.ContentType.APPLICATION_JSON.toString())); DocumentContext jsonPath = JsonPath.parse(response.getEntity().getContent()); jsonPath.<String>read("blobId"); assertThat(jsonPath.<String>read("type")).isEqualTo("application/octet-stream"); assertThat(jsonPath.<Integer>read("size")).isEqualTo(_1M); }
public void testFluentGenericTargetMapper() { configureByTestName(); assertThat( myItems ) .extracting( LookupElement::getLookupString ) .containsExactlyInAnyOrder( "id", "value" ); assertThat( myItems ) .extracting( LookupElementPresentation::renderElement ) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( createVariable( "id", "String" ), createVariable( "value", "String" ) ); }
@Test public void shouldCreatePartitionsWithMorePartitionsAndNodes() { // given final PartitionsLeaderMatrix partitionsLeaderMatrix = new PartitionsLeaderMatrix(6, 5, 3); // then final int[][] matrix = partitionsLeaderMatrix.matrix; assertThat(matrix).hasSize(6); assertThat(matrix).extracting(v -> v.length).containsOnly(5); assertThat(matrix[0]).containsExactly(LEADER, FOLLOWER, FOLLOWER, 0, 0); assertThat(matrix[1]).containsExactly(0, LEADER, FOLLOWER, FOLLOWER, 0); assertThat(matrix[2]).containsExactly(0, 0, LEADER, FOLLOWER, FOLLOWER); assertThat(matrix[3]).containsExactly(FOLLOWER, 0, 0, LEADER, FOLLOWER); assertThat(matrix[4]).containsExactly(FOLLOWER, FOLLOWER, 0, 0, LEADER); assertThat(matrix[5]).containsExactly(LEADER, FOLLOWER, FOLLOWER, 0, 0); }
@Test public void shouldCreatePartitionsWithMorePartitionsAndNodes() { // given final PartitionsLeaderMatrix partitionsLeaderMatrix = new PartitionsLeaderMatrix(6, 5, 3); // then final int[][] matrix = partitionsLeaderMatrix.matrix; assertThat(matrix).hasSize(6); assertThat(matrix).extracting(v -> v.length).containsOnly(5); assertThat(matrix[0]).containsExactly(LEADER, FOLLOWER, FOLLOWER, 0, 0); assertThat(matrix[1]).containsExactly(0, LEADER, FOLLOWER, FOLLOWER, 0); assertThat(matrix[2]).containsExactly(0, 0, LEADER, FOLLOWER, FOLLOWER); assertThat(matrix[3]).containsExactly(FOLLOWER, 0, 0, LEADER, FOLLOWER); assertThat(matrix[4]).containsExactly(FOLLOWER, FOLLOWER, 0, 0, LEADER); assertThat(matrix[5]).containsExactly(LEADER, FOLLOWER, FOLLOWER, 0, 0); }