List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:com.tilab.fiware.metaware.service.DiscoverObjServiceTest.java
/** * Test of discoverUsable method, of class DiscoverObjService. *///from w ww.j a va2 s . c o m @Test public void testDiscoverUsable() { System.out.println("discoverUsable"); String id = userId1; DiscoverObjService instance = new DiscoverObjService(); List expResult = new ArrayList(); expResult.add(algo1); expResult.add(data1); List result = instance.discoverUsable(id); assertTrue(expResult.containsAll(result) && result.containsAll(expResult)); }
From source file:org.mitre.openid.connect.client.service.impl.TestSignedAuthRequestUrlBuilder.java
/** * This test takes the URI from the result of building a signed request * and checks that the JWS object parsed from the request URI matches up * with the expected claim values./* ww w. j a v a2 s . co m*/ */ @Test public void buildAuthRequestUrl() { String requestUri = urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, redirectUri, nonce, state, options, null); // parsing the result UriComponentsBuilder builder = null; try { builder = UriComponentsBuilder.fromUri(new URI(requestUri)); } catch (URISyntaxException e1) { fail("URISyntaxException was thrown."); } UriComponents components = builder.build(); String jwtString = components.getQueryParams().get("request").get(0); JWTClaimsSet claims = null; try { SignedJWT jwt = SignedJWT.parse(jwtString); claims = jwt.getJWTClaimsSet(); } catch (ParseException e) { fail("ParseException was thrown."); } assertEquals(responseType, claims.getClaim("response_type")); assertEquals(clientConfig.getClientId(), claims.getClaim("client_id")); List<String> scopeList = Arrays.asList(((String) claims.getClaim("scope")).split(" ")); assertTrue(scopeList.containsAll(clientConfig.getScope())); assertEquals(redirectUri, claims.getClaim("redirect_uri")); assertEquals(nonce, claims.getClaim("nonce")); assertEquals(state, claims.getClaim("state")); for (String claim : options.keySet()) { assertEquals(options.get(claim), claims.getClaim(claim)); } }
From source file:org.mitre.openid.connect.client.service.impl.TestSignedAuthRequestUrlBuilder.java
@Test public void buildAuthRequestUrl_withLoginHint() { String requestUri = urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, redirectUri, nonce, state, options, loginHint);//from ww w .j av a2 s .c om // parsing the result UriComponentsBuilder builder = null; try { builder = UriComponentsBuilder.fromUri(new URI(requestUri)); } catch (URISyntaxException e1) { fail("URISyntaxException was thrown."); } UriComponents components = builder.build(); String jwtString = components.getQueryParams().get("request").get(0); JWTClaimsSet claims = null; try { SignedJWT jwt = SignedJWT.parse(jwtString); claims = jwt.getJWTClaimsSet(); } catch (ParseException e) { fail("ParseException was thrown."); } assertEquals(responseType, claims.getClaim("response_type")); assertEquals(clientConfig.getClientId(), claims.getClaim("client_id")); List<String> scopeList = Arrays.asList(((String) claims.getClaim("scope")).split(" ")); assertTrue(scopeList.containsAll(clientConfig.getScope())); assertEquals(redirectUri, claims.getClaim("redirect_uri")); assertEquals(nonce, claims.getClaim("nonce")); assertEquals(state, claims.getClaim("state")); for (String claim : options.keySet()) { assertEquals(options.get(claim), claims.getClaim(claim)); } assertEquals(loginHint, claims.getClaim("login_hint")); }
From source file:com.ning.metrics.collector.processing.db.TestCounterStorage.java
@Test(groups = { "slow", "database" }) public void testGetSubscritionIdsFromDailyMetrics() { Multimap<String, CounterEventData> events = ArrayListMultimap.create(); DateTime dateTime = new DateTime(DateTimeZone.UTC); events.put("1", prepareCounterEventData("member123", Arrays.asList("pageView", "trafficTablet", "contribution"), dateTime)); events.put("2", prepareCounterEventData("member321", Arrays.asList("pageView", "trafficMobile"), dateTime)); events.put("3", prepareCounterEventData("member123", Arrays.asList("pageView", "trafficTablet"), dateTime.plusHours(1)));//w ww .j a v a 2s .c o m counterStorage.bufferMetrics(events); List<String> namespaces = counterStorage.getNamespacesFromMetricsBuffer(); Assert.assertNotNull(namespaces); Assert.assertTrue(namespaces.containsAll(Lists.asList("1", new String[] { "2", "3" }))); }
From source file:org.languagetool.rules.spelling.morfologik.suggestions_ordering.SuggestionsOrdererTest.java
private void testOrderingHappened(Language language, String rule_id) throws IOException { JLanguageTool languageTool = new JLanguageTool(language); SuggestionsOrderer suggestionsOrderer = new SuggestionsOrdererGSoC(language, null, rule_id); String word = "wprd"; String sentence = String.join(" ", "a", word, "containing", "sentence"); LinkedList<String> suggestions = new LinkedList<>(); suggestions.add("word"); suggestions.add("weird"); int startPos = sentence.indexOf(word); int wordLength = word.length(); List<String> suggestionsOrdered = suggestionsOrderer.orderSuggestionsUsingModel(suggestions, word, languageTool.getAnalyzedSentence(sentence), startPos); assertTrue(suggestionsOrdered.containsAll(suggestions)); }
From source file:org.spring.cache.CachingWithConcurrentMapUsingExplicitlyNamedCachesTest.java
@Test public void numberCategoryCaching() { assertThat(numberClassificationService.wasCacheMiss(), is(false)); List<NumberClassification> twoCategories = numberClassificationService.classify(2.0); assertThat(twoCategories, is(notNullValue())); assertThat(twoCategories.size(), is(equalTo(3))); assertThat(twoCategories.containsAll(Arrays.asList(NumberClassification.EVEN, NumberClassification.POSITIVE, NumberClassification.WHOLE)), is(true)); assertThat(numberClassificationService.wasCacheMiss(), is(true)); List<NumberClassification> twoCategoriesAgain = numberClassificationService.classify(2.0); assertThat(twoCategoriesAgain, is(sameInstance(twoCategories))); assertThat(numberClassificationService.wasCacheMiss(), is(false)); List<NumberClassification> negativeThreePointFiveCategories = numberClassificationService.classify(-3.5); assertThat(negativeThreePointFiveCategories, is(notNullValue())); assertThat(negativeThreePointFiveCategories.size(), is(equalTo(3))); assertThat(negativeThreePointFiveCategories.containsAll(Arrays.asList(NumberClassification.ODD, NumberClassification.NEGATIVE, NumberClassification.FLOATING)), is(true)); assertThat(numberClassificationService.wasCacheMiss(), is(true)); }
From source file:net.dovemq.transport.endpoint.DoveMQMessageCodecTest.java
private void messageCodecTest(boolean setAppProperty, boolean setDeliveryAnnotation, boolean setMessageAnnotation, boolean setFooter, int messageCount) { CAMQPEncoder encoder = CAMQPEncoder.createCAMQPEncoder(); DoveMQMessageImpl message = new DoveMQMessageImpl(); if (setAppProperty) message.addApplicationProperty("appPropKey", "appPropVal"); if (setDeliveryAnnotation) message.addDeliveryAnnotation("deliveryKey", "deliveryVal"); if (setFooter) message.addFooter("footerkey", "footerval"); if (setMessageAnnotation) message.addMessageAnnotation("messageAnnotKey", "messageAnnotVal"); List<String> inPayloads = new ArrayList<String>(); for (int i = 0; i < messageCount; i++) { String payload = RandomStringUtils.randomAlphanumeric(1024); inPayloads.add(payload);/*w ww. j a v a 2s. c om*/ byte[] payloadBytes = payload.getBytes(); message.addPayload(payloadBytes); } message.encode(encoder); ChannelBuffer buffer = encoder.getEncodedBuffer(); CAMQPSyncDecoder inputPipe = CAMQPSyncDecoder.createCAMQPSyncDecoder(); inputPipe.take(buffer); DoveMQMessageImpl outMessage = DoveMQMessageImpl.decode(inputPipe); if (setAppProperty) assertTrue("appPropVal".equals(outMessage.getApplicationProperty("appPropKey"))); if (setDeliveryAnnotation) assertTrue("deliveryVal".equals(outMessage.getDeliveryAnnotation("deliveryKey"))); if (setMessageAnnotation) assertTrue("messageAnnotVal".equals(outMessage.getMessageAnnotation("messageAnnotKey"))); if (setFooter) assertTrue("footerval".equals(outMessage.getFooter("footerkey"))); Collection<byte[]> payloads = outMessage.getPayloads(); if (messageCount == 0) assertTrue(payloads == null); else { assertTrue(payloads.size() == messageCount); List<String> outPayloads = new ArrayList<String>(); for (byte[] payload : payloads) { outPayloads.add(new String(payload)); } assertTrue(outPayloads.containsAll(inPayloads)); } }
From source file:com.tilab.fiware.metaware.service.CompanyServiceTest.java
/** * Test of getCompaniesList method, of class CompanyService. * * @throws com.fasterxml.jackson.core.JsonProcessingException *//*from w w w .j av a 2 s. c o m*/ @Test public void testGetCompaniesList() throws JsonProcessingException { compId1 = INSTANCE.getCompanyService().createCompany(comp1); compId2 = INSTANCE.getCompanyService().createCompany(comp2); System.out.println("getCompaniesList"); CompanyService instance = INSTANCE.getCompanyService(); List<Company> expResult = new ArrayList<>(); expResult.add(comp1); expResult.add(comp2); List<Company> result = instance.getCompaniesList(); assertTrue(expResult.containsAll(result) && result.containsAll(expResult)); instance.deleteCompany(compId1); instance.deleteCompany(compId2); }
From source file:io.udvi.amqp.mq.transport.endpoint.UdviMQMessageCodecTest.java
private void messageCodecTest(boolean setAppProperty, boolean setDeliveryAnnotation, boolean setMessageAnnotation, boolean setFooter, int messageCount) { CAMQPEncoder encoder = CAMQPEncoder.createCAMQPEncoder(); UdviMQMessageImpl message = new UdviMQMessageImpl(); if (setAppProperty) message.addApplicationProperty("appPropKey", "appPropVal"); if (setDeliveryAnnotation) message.addDeliveryAnnotation("deliveryKey", "deliveryVal"); if (setFooter) message.addFooter("footerkey", "footerval"); if (setMessageAnnotation) message.addMessageAnnotation("messageAnnotKey", "messageAnnotVal"); List<String> inPayloads = new ArrayList<String>(); for (int i = 0; i < messageCount; i++) { String payload = RandomStringUtils.randomAlphanumeric(1024); inPayloads.add(payload);//from w w w .j ava 2s .co m byte[] payloadBytes = payload.getBytes(); message.addPayload(payloadBytes); } message.encode(encoder); ChannelBuffer buffer = encoder.getEncodedBuffer(); CAMQPSyncDecoder inputPipe = CAMQPSyncDecoder.createCAMQPSyncDecoder(); inputPipe.take(buffer); UdviMQMessageImpl outMessage = UdviMQMessageImpl.decode(inputPipe); if (setAppProperty) assertTrue("appPropVal".equals(outMessage.getApplicationProperty("appPropKey"))); if (setDeliveryAnnotation) assertTrue("deliveryVal".equals(outMessage.getDeliveryAnnotation("deliveryKey"))); if (setMessageAnnotation) assertTrue("messageAnnotVal".equals(outMessage.getMessageAnnotation("messageAnnotKey"))); if (setFooter) assertTrue("footerval".equals(outMessage.getFooter("footerkey"))); Collection<byte[]> payloads = outMessage.getPayloads(); if (messageCount == 0) assertTrue(payloads == null); else { assertTrue(payloads.size() == messageCount); List<String> outPayloads = new ArrayList<String>(); for (byte[] payload : payloads) { outPayloads.add(new String(payload)); } assertTrue(outPayloads.containsAll(inPayloads)); } }
From source file:com.vmware.identity.saml.impl.TokenValidatorImpl.java
/** * Checks if the group list from the token is equal to the current group list * for the given principal//from w w w.j av a 2 s.com * * @param groupList * required * @param subject * required * @throws InvalidTokenException * if the token group list differs from the current group list */ private void checkGroupList(List<PrincipalId> groupList, PrincipalId subject) throws InvalidTokenException, SystemException { // TODO pass attributes for which validation should be performed PrincipalAttributeDefinition groupAttributeDefinition = getSupportedAttributeDefinition(GROUP); if (groupAttributeDefinition == null) { throw new InvalidTokenException(GROUP + " is not supported attribute in token attributes."); } final PrincipalAttribute groupAttribute; try { groupAttribute = getAttribute(subject, groupAttributeDefinition); } catch (InvalidPrincipalException e) { throw new InvalidTokenException(String.format( "Principal %s not found, race condition suspected since the principal has just been validated.", subject), e); } List<PrincipalId> currentGroupList = toGroupList(groupAttribute.getValues()); List<PrincipalId> tokenGroupList = groupList; if (tokenGroupList.size() != currentGroupList.size() || !tokenGroupList.containsAll(currentGroupList)) { throw new InvalidTokenException( "Current group membership of " + "the principal is different from the one stated in the token"); } }