Refine search
@Test public void getMetricKeys_includes_by_default_new_lines() { QualityGate gate = mock(QualityGate.class); assertThat(underTest.getMetricKeys(gate)).containsExactly(NEW_LINES_KEY); }
@Test public void should_find_files_per_module_and_globally() throws IOException { InputComponentStoreTester tester = new InputComponentStoreTester(); String mod1Key = "mod1"; InputFile mod1File = tester.addFile(mod1Key, "src/main/java/Foo.java", "java"); String mod2Key = "mod2"; InputFile mod2File = tester.addFile(mod2Key, "src/main/groovy/Foo.groovy", "groovy"); assertThat(tester.filesByModule(mod1Key)).containsExactly(mod1File); assertThat(tester.filesByModule(mod2Key)).containsExactly(mod2File); assertThat(tester.inputFiles()).containsExactlyInAnyOrder(mod1File, mod2File); } }
private void assertMultiValueParameters(MapEntry<String, List<String>>... expectedParameters) { Parameters parameters = underTest.getParameters(); String[] expectedKeys = Arrays.stream(expectedParameters).map(MapEntry::getKey).toArray(String[]::new); assertThat(parameters.getKeys()).containsExactly(expectedKeys); Arrays.stream(expectedParameters).forEach(expectedParameter -> { assertThat(parameters.getValues(expectedParameter.getKey())).containsExactly(expectedParameter.getValue().toArray(new String[0])); }); }
@Test public void getIndexTypes() { assertThat(underTest.getIndexTypes()).containsExactly(INDEX_TYPE_ACTIVE_RULE); }
@Test public void should_add_languages_per_module_and_globally() throws IOException { InputComponentStoreTester tester = new InputComponentStoreTester(); String mod1Key = "mod1"; tester.addFile(mod1Key, "src/main/java/Foo.java", "java"); String mod2Key = "mod2"; tester.addFile(mod2Key, "src/main/groovy/Foo.groovy", "groovy"); assertThat(tester.languages(mod1Key)).containsExactly("java"); assertThat(tester.languages(mod2Key)).containsExactly("groovy"); assertThat(tester.languages()).containsExactlyInAnyOrder("java", "groovy"); }
@SafeVarargs private final <T extends Duplicate> void assertGetDuplicatesSorting(T... expected) { Duplication duplication = new Duplication(SOME_ORIGINAL_TEXTBLOCK, shuffledList(expected)); assertThat(duplication.getDuplicates()).containsExactly(expected); }
@Test public void test_getIndexTypes() { assertThat(underTest.getIndexTypes()).containsExactly(INDEX_TYPE_ISSUE); }
@Test public void selectUuidsOfOrganizationsWithoutDefaultProfile() { OrganizationDto org1 = dbTester.organizations().insert(); OrganizationDto org2 = dbTester.organizations().insert(); QProfileDto profileInOrg1 = dbTester.qualityProfiles().insert(org1, p -> p.setLanguage("java")); QProfileDto profileInOrg2 = dbTester.qualityProfiles().insert(org2, p -> p.setLanguage("java")); dbTester.qualityProfiles().setAsDefault(profileInOrg1); assertThat(underTest.selectUuidsOfOrganizationsWithoutDefaultProfile(dbSession, "java")) .containsExactly(org2.getUuid()); assertThat(underTest.selectUuidsOfOrganizationsWithoutDefaultProfile(dbSession, "js")) .containsExactlyInAnyOrder(org1.getUuid(), org2.getUuid()); }
private void assertLoaded() throws Exception { Collection<UserDetails> users = factory.getObject(); UserDetails expectedUser = User.withUsername("user") .password("password") .authorities("ROLE_USER") .build(); assertThat(users).containsExactly(expectedUser); } }
@Test public void test_getIndexTypes() { assertThat(underTest.getIndexTypes()).containsExactly(INDEX_TYPE_COMPONENT); }
@Test public void convertWhenTokenHasBothScopeAndScpThenScopeAttributeIsTranslatedToAuthorities() { Map<String, Object> claims = new HashMap<>(); claims.put("scp", Arrays.asList("message:read", "message:write")); claims.put("scope", "missive:read missive:write"); Jwt jwt = this.jwt(claims); Collection<GrantedAuthority> authorities = this.jwtGrantedAuthoritiesConverter.convert(jwt); assertThat(authorities).containsExactly( new SimpleGrantedAuthority("SCOPE_missive:read"), new SimpleGrantedAuthority("SCOPE_missive:write")); }
@Test public void validate_and_sanitize_collection_of_tags() { assertThat(RuleTagFormat.validate(asList("style", "coding-style", ""))).containsExactly("coding-style", "style"); assertThat(RuleTagFormat.validate(asList("style", "coding-style", null))).containsExactly("coding-style", "style"); assertThat(RuleTagFormat.validate(asList("style", "style", null))).containsExactly("style"); assertThat(RuleTagFormat.validate(singletonList("Uppercase"))).containsExactly("uppercase"); assertThat(RuleTagFormat.validate(Collections.emptyList())).isEmpty(); }
@Test public void convertWhenTokenHasEmptyScopeAndNonEmptyScpThenScopeAttributeIsTranslatedToNoAuthorities() { Map<String, Object> claims = new HashMap<>(); claims.put("scp", Arrays.asList("message:read", "message:write")); claims.put("scope", ""); Jwt jwt = this.jwt(claims); Collection<GrantedAuthority> authorities = this.jwtGrantedAuthoritiesConverter.convert(jwt); assertThat(authorities).containsExactly(); }
@Test public void convertWhenTokenHasScpAttributeThenTranslatedToAuthorities() { Jwt jwt = this.jwt(Collections.singletonMap("scp", Arrays.asList("message:read", "message:write"))); Collection<GrantedAuthority> authorities = this.jwtGrantedAuthoritiesConverter.convert(jwt); assertThat(authorities).containsExactly( new SimpleGrantedAuthority("SCOPE_message:read"), new SimpleGrantedAuthority("SCOPE_message:write")); }
@Test public void toHashSet_with_size_builds_an_ArrayList() { Set<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toHashSet(30)); assertThat(res).isInstanceOf(HashSet.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void toSet_builds_an_ImmutableSet() { Set<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toSet()); assertThat(res).isInstanceOf(ImmutableSet.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void toHashSet_builds_an_HashSet() { Set<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toHashSet()); assertThat(res).isInstanceOf(HashSet.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void convertWhenTokenHasScopeAttributeThenTranslatedToAuthorities() { Jwt jwt = this.jwt(Collections.singletonMap("scope", "message:read message:write")); Collection<GrantedAuthority> authorities = this.jwtGrantedAuthoritiesConverter.convert(jwt); assertThat(authorities).containsExactly( new SimpleGrantedAuthority("SCOPE_message:read"), new SimpleGrantedAuthority("SCOPE_message:write")); }
@Test public void toSet_with_size_builds_an_ImmutableSet() { Set<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toSet(30)); assertThat(res).isInstanceOf(ImmutableSet.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void toEnumSet() { Set<MyEnum> res = Stream.of(MyEnum.ONE, MyEnum.ONE, MyEnum.TWO).collect(MoreCollectors.toEnumSet(MyEnum.class)); assertThat(res).isInstanceOf(EnumSet.class) .containsExactly(MyEnum.ONE, MyEnum.TWO); }