List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:eu.freme.eservices.epublishing.webservice.EPUBCreationTest.java
@Ignore @Test/*from w ww.ja va 2 s .c o m*/ public void testAuthors() throws IOException, InvalidZipException, EPubCreationException, MissingMetadataException { String anotherAuthor = "Nick Borth"; Metadata metadata = getSimpleMetadataForZip(); //metadata.addAuthor(anotherAuthor); byte[] epub = getePublishingService().createEPUB(metadata, new FileInputStream(getZipFile())); // write it to a (temporary) file File ePubFile = File.createTempFile("alice", ".epub"); System.out.println("Writing result to " + ePubFile); IOUtils.copy(new ByteArrayInputStream(epub), new FileOutputStream(ePubFile)); //read file and perform checks EpubReader r = new EpubReader(); Book b = r.readEpub(new FileInputStream(ePubFile)); List<CreatorContributor> bookAuthors = b.getMetadata().getAuthors(); List<String> bookAuthorsNames = new ArrayList<>(); for (CreatorContributor a : bookAuthors) { bookAuthorsNames.add(a.getFirstname() + " " + a.getLastname()); } System.out.println(bookAuthorsNames); Assert.assertTrue("All authors are in the EPUB.", bookAuthorsNames.containsAll(metadata.getAuthors())); Assert.assertTrue("All EPUB authors are in the given authors.", metadata.getAuthors().containsAll(bookAuthorsNames)); }
From source file:org.squashtest.tm.service.internal.requirement.CustomRequirementVersionManagerServiceImpl.java
@Override public boolean haveSamePerimeter(List<Long> reqVersionIds) { if (reqVersionIds.size() != 1) { Long first = reqVersionIds.remove(0); List<Milestone> toCompare = requirementVersionDao.findOne(first).getProject().getMilestones(); for (Long reqVersionId : reqVersionIds) { List<Milestone> mil = requirementVersionDao.findOne(reqVersionId).getProject().getMilestones(); if (mil.size() != toCompare.size() || !mil.containsAll(toCompare)) { return false; }/*w w w . j a v a 2 s .c o m*/ } } return true; }
From source file:org.spring.data.gemfire.cache.ClientCacheFunctionExecutionWithStreamingTest.java
@Test public void testClientServerFunctionExecution() { GemfireOnRegionFunctionTemplate onNumbersFunctionTemplate = new GemfireOnRegionFunctionTemplate(numbers); assertThat(onNumbersFunctionTemplate.executeAndextract("addition", Collections.emptySet(), "one", "two"), is(equalTo(3)));//from w ww. j a v a 2 s. com GemfireOnRegionFunctionTemplate onCollectionsFunctionTemplate = new GemfireOnRegionFunctionTemplate( collections); List<Object> integers = onCollectionsFunctionTemplate.executeAndextract("streaming", Collections.emptySet(), "one"); assertNotNull(integers); //assertEquals(10, integers.size()); //assertTrue(integers.containsAll(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9))); assertEquals(2, integers.size()); assertTrue(integers.containsAll(Arrays.asList(0, 1))); assertThat(onNumbersFunctionTemplate.executeAndextract("addition", Collections.emptySet(), "four", "five"), is(equalTo(9))); List<Object> strings = onCollectionsFunctionTemplate.executeAndextract("streaming", Collections.emptySet(), "two"); assertNotNull(strings); //assertEquals(3, strings.size()); //assertTrue(strings.containsAll(Arrays.asList("assert", "mock", "test"))); assertEquals(2, strings.size()); assertTrue(strings.containsAll(Arrays.asList("assert", "mock"))); }
From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java
/** * Associer une liste de types une catgorie. * @param typeIds// ww w. j ava2 s . c o m * @param categoryId * @throws CategoryException */ @Transactional(readOnly = false) public void addAuthorizedTypeToCategory(final List<Long> typeIds, final Long categoryId) throws CategoryException { try { List<Type> types = this.entityDao .getAuthorizedTypesOfEntity(this.categoryDao.getCategoryById(categoryId).getEntityId()); List<Long> tids = new ArrayList<Long>(); for (Type t : types) { tids.add(t.getTypeId()); } if (tids.containsAll(typeIds)) { this.categoryDao.addTypesToCategory(typeIds, categoryId); } else { throw new CategoryException( "Certains des types spcifis ne sont pas autoriss pour la catgorie."); } } catch (DataAccessException e) { LOG.error("Add Authorized Type To Category error : " + e.getLocalizedMessage()); throw e; } }
From source file:com.manydesigns.elements.forms.AbstractFormBuilder.java
protected void removeUnusedSelectionProviders(Collection<PropertyAccessor> propertyAccessors) { List<String> propertyNames = new ArrayList<String>(); for (PropertyAccessor propertyAccessor : propertyAccessors) { propertyNames.add(propertyAccessor.getName()); }//from w w w.j av a 2 s.c o m List<String[]> removeList = new ArrayList<String[]>(); for (String[] current : selectionProviders.keySet()) { List<String> currentNames = Arrays.asList(current); if (!propertyNames.containsAll(currentNames)) { removeList.add(current); } } for (String[] current : removeList) { selectionProviders.remove(current); } }
From source file:cz.swi2.mendeluis.dataaccesslayer.domain.UserFavouriteItemTest.java
@org.testng.annotations.Test public void testGetAll() { // Create entities User u = new User("michal", "michal", "pw123456"); FavouriteItem f1 = new FavouriteItem("Food menu xx"); FavouriteItem f2 = new FavouriteItem("Food menu x2"); UserFavouriteItem uf1 = new UserFavouriteItem(u, f1, 0); UserFavouriteItem uf2 = new UserFavouriteItem(u, f2, 0); // Insert //from w w w .j a v a 2 s .c om this.userRepository.insert(u); this.favouriteItemRepository.insert(f1); this.favouriteItemRepository.insert(f2); this.userFavouriteItemRepository.insert(uf1); this.userFavouriteItemRepository.insert(uf2); // Fetch all user userFavouriteItems List<UserFavouriteItem> results = this.userFavouriteItemRepository.getAll(); // Prepare a list to be compared List<UserFavouriteItem> favi = new ArrayList(); favi.add(uf1); favi.add(uf2); // We do not use a different db for testing. Thefore we must test only matching items, not all. assertTrue(results.containsAll(favi)); }
From source file:org.keycloak.testsuite.console.authentication.FlowsTest.java
@Test public void requirementTest() { //rest: add or copy flow to test navigation (browser), add reset, password flowsPage.selectFlowOption(Flows.FlowOption.BROWSER); flowsPage.table().changeRequirement("Cookie", FlowsTable.RequirementOption.DISABLED); assertAlertSuccess();// w w w. ja va 2 s . com flowsPage.table().changeRequirement("Kerberos", FlowsTable.RequirementOption.REQUIRED); assertAlertSuccess(); flowsPage.table().changeRequirement("Kerberos", FlowsTable.RequirementOption.ALTERNATIVE); assertAlertSuccess(); flowsPage.table().changeRequirement("OTP Form", FlowsTable.RequirementOption.DISABLED); assertAlertSuccess(); flowsPage.table().changeRequirement("OTP Form", FlowsTable.RequirementOption.OPTIONAL); assertAlertSuccess(); //UI List<String> expectedOrder = new ArrayList<>(); Collections.addAll(expectedOrder, "DISABLED", "ALTERNATIVE", "ALTERNATIVE", "ALTERNATIVE", "REQUIRED", "OPTIONAL"); assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().values())); //REST: List<AuthenticationExecutionExportRepresentation> browserFlow = testRealmResource().flows().getFlows() .get(0).getAuthenticationExecutions(); assertEquals("DISABLED", browserFlow.get(0).getRequirement()); assertEquals("ALTERNATIVE", browserFlow.get(1).getRequirement()); assertEquals("ALTERNATIVE", browserFlow.get(2).getRequirement()); }
From source file:org.talend.dataprep.transformation.service.TransformationServiceTest.java
/** * see https://jira.talendforge.org/browse/TDP-3126 */// w w w . j av a2s .c o m @Test public void shouldGetPreparationColumnTypesWhenDomainIsForced() throws Exception { // given final String dataSetId = createDataset("first_interactions_400.csv", "first interactions", "text/csv"); final String preparationId = createEmptyPreparationFromDataset(dataSetId, "first interactions"); // (force the domain to gender to replace all the 'F' by 'France') applyActionFromFile(preparationId, "change_domain.json"); applyActionFromFile(preparationId, "replace_value.json"); // when final Response response = when().get("/preparations/{preparationId}/columns/{columnId}/types", preparationId, "0005"); // then assertEquals(200, response.getStatusCode()); final JsonNode rootNode = mapper.readTree(response.asInputStream()); assertEquals(5, rootNode.size()); final List<String> actual = new ArrayList<>(5); rootNode.forEach(n -> actual.add(n.get("id").textValue().toUpperCase())); final List<String> expected = Arrays.asList("COUNTRY", "CIVILITY", "GENDER", "LAST_NAME", "FIRST_NAME"); assertTrue(expected.containsAll(actual)); }
From source file:es.upm.fi.dia.oeg.ogsadai.sparql.optimizers.WellDesignedRule3Optimiser.java
/** * checks safe condition (variables in P1 are in P2 and P') * /* www. j a v a 2s. c o m*/ * @param ousideOperator * operator P' * @param optionalOperator * (P1 OPT P2) * * @return true if pattern is safe */ private boolean checkSafeCondition(Operator ousideOperator, Operator optionalOperator) { List<String> pPrimeAttrs = new ArrayList<String>(); // getting variables from left side of AND (parent operator) for (Attribute attribute : ousideOperator.getHeading().getAttributes()) { pPrimeAttrs.add(attribute.getName()); } // getting variables from P2 List<String> p2Attrs = new ArrayList<String>(); for (Attribute attribute : optionalOperator.getChild(1).getHeading().getAttributes()) { p2Attrs.add(attribute.getName()); } // p2Attrs.addAll(pPrimeAttrs); List<String> intersection = null; intersection = new ArrayList<String>(); intersection = ListUtils.intersection(pPrimeAttrs, p2Attrs); // getting variables from P2 List<String> p1Attrs = new ArrayList<String>(); for (Attribute attribute : optionalOperator.getChild(0).getHeading().getAttributes()) { p1Attrs.add(attribute.getName()); } if (p1Attrs.containsAll(intersection)) { return true; } return false; }
From source file:com.mobilesolutionworks.android.facebook.FacebookPluginFragment.java
private Task<Session> requestForPublish(final Session session, final boolean publish, final String... newPermissions) { checkActivity();//ww w . j av a 2 s .c o m final Task<Session>.TaskCompletionSource source = Task.<Session>create(); List<String> permissions = session.getPermissions(); if (permissions.containsAll(Arrays.asList(newPermissions))) { source.trySetResult(session); } else { getActivity().runOnUiThread(new Runnable() { @Override public void run() { Session.NewPermissionsRequest request = new Session.NewPermissionsRequest( FacebookPluginFragment.this, newPermissions); request.setRequestCode(REQUEST_CODE); request.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); request.setCallback(new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if (state.isClosed()) { source.trySetError(exception); } else if (state.isOpened()) { source.trySetResult(session); } } }); if (publish) { session.requestNewPublishPermissions(request); } else { session.requestNewReadPermissions(request); } } }); } return source.getTask(); }