@Test public void index_with_valueFunction_parallel_stream() { Multimap<String, String> multimap = HUGE_LIST.parallelStream().collect(index(identity(), identity())); assertThat(multimap.keySet()).isEqualTo(HUGE_SET); }
@Test public void uniqueIndex_with_valueFunction_and_expected_size_parallel_stream() { Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity(), identity(), HUGE_LIST.size())); assertThat(map.keySet()).isEqualTo(HUGE_SET); assertThat(map.values()).containsExactlyElementsOf(HUGE_SET); }
@Test public void uniqueIndex_with_expected_size_parallel_stream() { Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity(), HUGE_LIST.size())); assertThat(map.keySet()).isEqualTo(HUGE_SET); assertThat(map.values()).containsExactlyElementsOf(HUGE_SET); }
@Test public void uniqueIndex_with_valueFunction_parallel_stream() { Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity(), identity())); assertThat(map.keySet()).isEqualTo(HUGE_SET); assertThat(map.values()).containsExactlyElementsOf(HUGE_SET); }
@Test public void CeWorkerFactory_must_returns_the_workers_returned_by_created() { Set<CeWorker> expected = new HashSet<>(); for (int i = 0; i < 1 + new Random().nextInt(10); i++) { expected.add(underTest.create(i)); } assertThat(underTest.getWorkers()).isEqualTo(expected); } }
@Test public void deserializeAuthenticatedUsernamePasswordAuthenticationTokenMixinTest() throws IOException { UsernamePasswordAuthenticationToken expectedToken = createToken(); UsernamePasswordAuthenticationToken token = mapper .readValue(AUTHENTICATED_STRINGPRINCIPAL_JSON, UsernamePasswordAuthenticationToken.class); assertThat(token).isNotNull(); assertThat(token.isAuthenticated()).isTrue(); assertThat(token.getAuthorities()).isEqualTo(expectedToken.getAuthorities()); }
@Test public void verify_getters() { List<QualityGate.Condition> conditions = ImmutableList.of(condition); QualityGateImpl underTest = new QualityGateImpl(SOME_ID, SOME_NAME, SOME_STATUS, conditions); assertThat(underTest.getId()).isEqualTo(SOME_ID); assertThat(underTest.getName()).isEqualTo(SOME_NAME); assertThat(underTest.getStatus()).isEqualTo(SOME_STATUS); assertThat(underTest.getConditions()).isEqualTo(conditions); }
@Test public void methodsWithDifferentArgumentsAreMatchedCorrectly() throws Exception { mds.addSecureMethod(MockService.class, someMethodInteger, ROLE_A); mds.addSecureMethod(MockService.class, someMethodString, ROLE_B); assertThat(mds.getAttributes(someMethodInteger, MockService.class)).isEqualTo(ROLE_A); assertThat(mds.getAttributes(someMethodString, MockService.class)).isEqualTo(ROLE_B); }
@Test public void checkCluster_returns_NodeHealths_returned_by_HealthState() { when(webServer.isStandalone()).thenReturn(false); Set<NodeHealth> nodeHealths = IntStream.range(0, 1 + random.nextInt(4)).mapToObj(i -> randomNodeHealth()).collect(Collectors.toSet()); when(sharedHealthState.readAll()).thenReturn(nodeHealths); HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState); ClusterHealth clusterHealth = underTest.checkCluster(); assertThat(clusterHealth.getNodes()).isEqualTo(nodeHealths); }
@Test public void constructorWhenAllParametersProvidedAndValidThenCreated() { OAuth2AuthenticationToken authentication = new OAuth2AuthenticationToken( this.principal, this.authorities, this.authorizedClientRegistrationId); assertThat(authentication.getPrincipal()).isEqualTo(this.principal); assertThat(authentication.getCredentials()).isEqualTo(""); assertThat(authentication.getAuthorities()).isEqualTo(this.authorities); assertThat(authentication.getAuthorizedClientRegistrationId()).isEqualTo(this.authorizedClientRegistrationId); assertThat(authentication.isAuthenticated()).isEqualTo(true); } }
@Test public void test_getters() { DefaultTrackingInput underTest = new DefaultTrackingInput(issues, lineHashes, blockHashes); assertThat(underTest.getBlockHashSequence()).isEqualTo(blockHashes); assertThat(underTest.getLineHashSequence()).isEqualTo(lineHashes); assertThat(underTest.getIssues()).isEqualTo(issues); } }
@Test @UseDataProvider("coreExtensionsSets") public void loadedCoreExtensions_returns_CoreExtensions_from_setLoadedCoreExtensions(Set<CoreExtension> coreExtensions) { underTest.setLoadedCoreExtensions(coreExtensions); assertThat(underTest.loadedCoreExtensions().collect(Collectors.toSet())) .isEqualTo(coreExtensions); }
@Test public void constructorAuthorizationRequestResponseWhenAllParametersProvidedAndValidThenCreated() { OAuth2LoginAuthenticationToken authentication = new OAuth2LoginAuthenticationToken( this.clientRegistration, this.authorizationExchange); assertThat(authentication.getPrincipal()).isNull(); assertThat(authentication.getCredentials()).isEqualTo(""); assertThat(authentication.getAuthorities()).isEqualTo(Collections.emptyList()); assertThat(authentication.getClientRegistration()).isEqualTo(this.clientRegistration); assertThat(authentication.getAuthorizationExchange()).isEqualTo(this.authorizationExchange); assertThat(authentication.getAccessToken()).isNull(); assertThat(authentication.isAuthenticated()).isEqualTo(false); }
@Test public void constructorAuthorizationRequestResponseWhenAllParametersProvidedAndValidThenCreated() { OAuth2AuthorizationCodeAuthenticationToken authentication = new OAuth2AuthorizationCodeAuthenticationToken(this.clientRegistration, this.authorizationExchange); assertThat(authentication.getPrincipal()).isEqualTo(this.clientRegistration.getClientId()); assertThat(authentication.getCredentials()).isEqualTo(this.authorizationExchange.getAuthorizationResponse().getCode()); assertThat(authentication.getAuthorities()).isEqualTo(Collections.emptyList()); assertThat(authentication.getClientRegistration()).isEqualTo(this.clientRegistration); assertThat(authentication.getAuthorizationExchange()).isEqualTo(this.authorizationExchange); assertThat(authentication.getAccessToken()).isNull(); assertThat(authentication.isAuthenticated()).isEqualTo(false); }
@Test public void constructorWhenAllParametersProvidedAndValidThenCreated() { OAuth2AccessToken accessToken = new OAuth2AccessToken( TOKEN_TYPE, TOKEN_VALUE, ISSUED_AT, EXPIRES_AT, SCOPES); assertThat(accessToken.getTokenType()).isEqualTo(TOKEN_TYPE); assertThat(accessToken.getTokenValue()).isEqualTo(TOKEN_VALUE); assertThat(accessToken.getIssuedAt()).isEqualTo(ISSUED_AT); assertThat(accessToken.getExpiresAt()).isEqualTo(EXPIRES_AT); assertThat(accessToken.getScopes()).isEqualTo(SCOPES); }
@Test public void withUserDetailsWhenAllDisabled() throws Exception { User expected = new User("rob", "pass", false, false, false, false, ROLE_12); UserDetails actual = User.withUserDetails(expected).build(); assertThat(actual.getUsername()).isEqualTo(expected.getUsername()); assertThat(actual.getPassword()).isEqualTo(expected.getPassword()); assertThat(actual.getAuthorities()).isEqualTo(expected.getAuthorities()); assertThat(actual.isAccountNonExpired()).isEqualTo(expected.isAccountNonExpired()); assertThat(actual.isAccountNonLocked()).isEqualTo(expected.isAccountNonLocked()); assertThat(actual.isCredentialsNonExpired()).isEqualTo(expected.isCredentialsNonExpired()); assertThat(actual.isEnabled()).isEqualTo(expected.isEnabled()); }
@Test public void wildcardedMatchIsOverwrittenByMoreSpecificMatch() { mds.addSecureMethod(MockService.class, "some*", ROLE_A); mds.addSecureMethod(MockService.class, "someMethod*", ROLE_B); assertThat(mds.getAttributes(someMethodInteger, MockService.class)).isEqualTo(ROLE_B); }
@Test public void testOperation() { List<ConfigAttribute> attr = SecurityConfig.createList("FOO"); MethodInvocation mi = new SimpleMethodInvocation(); SecurityContext ctx = SecurityContextHolder.createEmptyContext(); InterceptorStatusToken token = new InterceptorStatusToken(ctx, true, attr, mi); assertThat(token.isContextHolderRefreshRequired()).isTrue(); assertThat(token.getAttributes()).isEqualTo(attr); assertThat(token.getSecureObject()).isEqualTo(mi); assertThat(token.getSecurityContext()).isSameAs(ctx); } }
@Test public void verify_getters() { Health health = randomHealth(); Set<NodeHealth> nodeHealths = randomNodeHealths(); ClusterHealth underTest = new ClusterHealth(health, nodeHealths); assertThat(underTest.getHealth()).isSameAs(health); assertThat(underTest.getNodes()).isEqualTo(nodeHealths); }
@Test @UseDataProvider("portfolioOrApplicationRootViewQualifier") public void selectViewKeysWithEnabledCopyOfProject_returns_root_view_with_direct_copy_of_project(String rootViewQualifier) { OrganizationDto organization = db.organizations().insert(); ComponentDto project = insertProject(organization); ComponentDto view = insertView(organization, rootViewQualifier); insertProjectCopy(view, project); Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid())); assertThat(keys).containsOnly(view.getDbKey()); assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid()))) .isEqualTo(keys); }