List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:com.twosigma.beakerx.kernel.magic.command.ClasspathAddMvnDepsCellMagicCommandTest.java
private void handleCellClasspathAddMvnDep(String allCode, List<String> expected) throws Exception { processMagicCommand(allCode);/*from w w w . ja v a 2 s .co m*/ String mvnDir = kernel.getTempFolder().toString() + MavenJarResolver.MVN_DIR; List<String> depNames = Files.walk(Paths.get(mvnDir)).map(p -> p.getFileName().toString()) .collect(Collectors.toList()); Optional<Message> updateMessage = EvaluatorResultTestWatcher.waitForUpdateMessage(kernel); String text = (String) TestWidgetUtils.getState(updateMessage.get()).get("value"); Assertions.assertThat(kernel.getClasspath().get(0)).contains(mvnDir); Assertions.assertThat(expected.stream().allMatch(depNames::contains)); Assertions.assertThat(depNames.containsAll(expected)).isTrue(); Assertions.assertThat(expected.stream().allMatch(text::contains)).isTrue(); Files.walk(Paths.get(mvnDir)).forEach(path -> { try { FileUtils.forceDelete(path.toFile()); } catch (IOException e) { e.printStackTrace(); } }); }
From source file:org.finra.dm.rest.JobRestControllerTest.java
@Test public void testCreateJob() throws Exception { // Create the namespace entity. createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD); // Create a job definition create request using hard coded test values. JobDefinitionCreateRequest jobDefinitionCreateRequest = createJobDefinitionCreateRequest(); // Create the job definition. jobDefinitionRestController.createJobDefinition(jobDefinitionCreateRequest); // Create a job create request using hard coded test values. JobCreateRequest jobCreateRequest = createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);// w w w . jav a 2s. c o m // Create the job. Job resultJob = jobRestController.createJob(jobCreateRequest); // Validate the results. assertNotNull(resultJob); assertNotNull(resultJob.getId()); assertTrue(!resultJob.getId().isEmpty()); assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace()); assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName()); assertEquals(jobDefinitionCreateRequest.getParameters().size() + jobCreateRequest.getParameters().size(), resultJob.getParameters().size()); List<String> expectedParameters = new ArrayList<>(); expectedParameters.addAll(parametersToStringList(jobDefinitionCreateRequest.getParameters())); expectedParameters.addAll(parametersToStringList(jobCreateRequest.getParameters())); List<String> resultParameters = parametersToStringList(resultJob.getParameters()); assertTrue(expectedParameters.containsAll(resultParameters)); assertTrue(resultParameters.containsAll(expectedParameters)); }
From source file:com.splicemachine.derby.utils.SpliceAdminIT.java
@Test public void testGetConglomerateIDs() throws Exception { String TABLE_NAME = "ZONING"; SpliceUnitTest.MyWatcher tableWatcher = new SpliceUnitTest.MyWatcher(TABLE_NAME, CLASS_NAME, "(PARCELID INTEGER UNIQUE NOT NULL, ADDRESS VARCHAR(15), BOARDDEC VARCHAR(11), EXSZONE VARCHAR(8), PRPZONE VARCHAR(8), HEARDATE DATE)"); tableDAO.drop(CLASS_NAME, TABLE_NAME); tableWatcher.create(Description.createSuiteDescription(CLASS_NAME, "testGetConglomerateIDs")); List<Map> tableCluster = TestUtils.tableLookupByNumberNoPrint(methodWatcher); List<Long> actualConglomIDs = new ArrayList<Long>(); TestConnection conn = methodWatcher.getOrCreateConnection(); long[] conglomids = conn.getConglomNumbers(CLASS_NAME, TABLE_NAME); Assert.assertTrue(conglomids.length > 0); for (long conglomID : conglomids) { actualConglomIDs.add(conglomID); }//from ww w.j a va2 s .co m List<Long> expectedConglomIDs = new ArrayList<Long>(); for (Map m : tableCluster) { if (m.get("TABLENAME").equals(TABLE_NAME)) { expectedConglomIDs.add((Long) m.get("CONGLOMERATENUMBER")); } } Assert.assertTrue("Expected: " + expectedConglomIDs + " got: " + actualConglomIDs, expectedConglomIDs.containsAll(actualConglomIDs)); }
From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java
public void assertOptionPresent(String selectField, String[] options) { assertElementPresent(selectField);//www. j av a 2 s . co m String[] optionsPresent = getSelenium().getSelectOptions(selectField); List<String> expected = Arrays.asList(options); List<String> present = Arrays.asList(optionsPresent); Assert.assertTrue("Options expected are not included in present options", present.containsAll(expected)); }
From source file:com.nextep.designer.sqlclient.ui.services.impl.SQLClientService.java
private boolean checkColumnsCoverPK(List<String> columnNames, List<IBasicColumn> pkColumns) { List<String> pkColNames = NameHelper.buildNameList(pkColumns); return columnNames.containsAll(pkColNames); }
From source file:gov.nih.nci.caarray.plugins.illumina.CsvDataHandler.java
private void checkSdrfHybridizations(FileValidationResult result, List<String> fileHybNames, Map<String, List<Hybridization>> sdrfHybsMap) { // get collection of hyb names from sdrf as strings for (final List<Hybridization> hybList : sdrfHybsMap.values()) { final List<String> sdrfHybStrs = new ArrayList<String>(); for (final Hybridization hyb : hybList) { sdrfHybStrs.add(hyb.getName()); }/*from ww w . j a va 2 s. c o m*/ if (!sdrfHybStrs.containsAll(fileHybNames)) { final StringBuilder sb = new StringBuilder( "This data file contains the following hybridization names" + " that are not referenced in the SDRF document:"); sdrfHybStrs.removeAll(fileHybNames); sb.append(StringUtils.join(sdrfHybStrs.iterator(), ',')); result.addMessage(Type.ERROR, sb.toString()); } } }
From source file:org.apache.jackrabbit.jcr2spi.state.NodeState.java
/** * @see ItemState#merge(ItemState, boolean) *//*w ww . ja v a 2 s . c om*/ public boolean merge(ItemState another, boolean keepChanges) { if (another == null || another == this) { return false; } if (!another.isNode()) { throw new IllegalArgumentException("Attempt to merge node state with property state."); } boolean modified = false; synchronized (another) { NodeState nState = (NodeState) another; if (nState.definition != null && !nState.definition.equals(definition)) { definition = nState.definition; modified = true; } // since 'mixinTypeNames' are modified upon save only, no special // merging is required here. just reset the mixinTypeNames. List mixN = Arrays.asList(nState.mixinTypeNames); if (mixN.size() != mixinTypeNames.length || !mixN.containsAll(Arrays.asList(mixinTypeNames))) { setMixinTypeNames(nState.mixinTypeNames); modified = true; } } return modified; }
From source file:org.openecomp.sdc.common.test.CommonUtilsTest.java
@Test public void removeDuplicateFromListTest() { List<String> tagsBefore = new ArrayList<>(); tagsBefore.add("tag1"); tagsBefore.add("tag7"); tagsBefore.add("tag3"); tagsBefore.add("tag4"); tagsBefore.add("tag1"); List<String> tagsAfter = new ArrayList<>(); tagsAfter.add("tag1"); tagsAfter.add("tag7"); tagsAfter.add("tag3"); tagsAfter.add("tag4"); assertTrue(tagsAfter.containsAll(ValidationUtils.removeDuplicateFromList(tagsBefore))); tagsBefore = new ArrayList<>(); tagsBefore.add("tag1"); tagsBefore.add("tag7"); tagsBefore.add("tag3"); tagsBefore.add("tag4"); tagsBefore.add("Tag1"); tagsAfter = new ArrayList<>(); tagsAfter.add("tag1"); tagsAfter.add("tag7"); tagsAfter.add("tag3"); tagsAfter.add("tag4"); tagsAfter.add("Tag1"); assertTrue(tagsAfter.containsAll(ValidationUtils.removeDuplicateFromList(tagsBefore))); }
From source file:org.apache.rya.mongodb.document.util.DisjunctiveNormalFormConverter.java
/** * Creates a document visibility boolean expression string into Disjunctive * Normal Form (DNF). Expressions use this format in DNF:<pre> * (P1 & P2 & P3 ... Pn) | (Q1 & Q2 ... Qm) ... * </pre>//from www . ja v a2 s.c o m * @param documentVisibility the {@link DocumentVisibility}. * @return a new {@link DocumentVisibility} with its expression in DNF. */ public static DocumentVisibility convertToDisjunctiveNormalForm(final DocumentVisibility documentVisibility) { // Find all the terms used in the expression final List<String> terms = findNodeTerms(documentVisibility.getParseTree(), documentVisibility.getExpression()); // Create an appropriately sized truth table that has the correct 0's // and 1's in place based on the number of terms. // This size should be [numberOfTerms][2 ^ numberOfTerms]. final byte[][] truthTable = createTruthTableInputs(terms); // Go through each row in the truth table. // If the row has a 1 for the term then create an Authorization for it // and test if it works. // If the row passes then that means all the terms that were a 1 and // were used can be AND'ed together to pass the expression. // All the rows that pass can be OR'd together. // Disjunction Normal Form: (P1 & P2 & P3 ... Pn) | (Q1 & Q2 ... Qm) ... final List<List<String>> termRowsThatPass = new ArrayList<>(); for (final byte[] row : truthTable) { final List<String> termRowToCheck = new ArrayList<>(); // If the truth table input is a 1 then include the corresponding // term that it matches. for (int i = 0; i < row.length; i++) { final byte entry = row[i]; if (entry == 1) { termRowToCheck.add(terms.get(i)); } } final List<String> authList = new ArrayList<>(); for (final String auth : termRowToCheck) { String formattedAuth = auth; formattedAuth = StringUtils.removeStart(formattedAuth, "\""); formattedAuth = StringUtils.removeEnd(formattedAuth, "\""); authList.add(formattedAuth); } final Authorizations auths = new Authorizations(authList.toArray(new String[0])); final boolean hasAccess = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, documentVisibility, false); if (hasAccess) { boolean alreadyCoveredBySimplerTerms = false; // If one 'AND' group is (A&C) and another is (A&B&C) then we // can drop (A&B&C) since it is already covered by simpler terms // (it's a subset) for (final List<String> existingTermRowThatPassed : termRowsThatPass) { alreadyCoveredBySimplerTerms = termRowToCheck.containsAll(existingTermRowThatPassed); if (alreadyCoveredBySimplerTerms) { break; } } if (!alreadyCoveredBySimplerTerms) { termRowsThatPass.add(termRowToCheck); } } } // Rebuild the term rows that passed as a document visibility boolean // expression string. final StringBuilder sb = new StringBuilder(); boolean isFirst = true; final boolean hasMultipleGroups = termRowsThatPass.size() > 1; for (final List<String> termRowThatPassed : termRowsThatPass) { if (isFirst) { isFirst = false; } else { sb.append("|"); } if (hasMultipleGroups && termRowThatPassed.size() > 1) { sb.append("("); } sb.append(Joiner.on("&").join(termRowThatPassed)); if (hasMultipleGroups && termRowThatPassed.size() > 1) { sb.append(")"); } } log.trace(sb.toString()); final DocumentVisibility dnfDv = new DocumentVisibility(sb.toString()); return dnfDv; }
From source file:org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCriteria.java
protected String getGlobalSecondaryIndexName() { // Lazy evaluate the globalSecondaryIndexName if not already set // We must have attribute conditions specified in order to use a global secondary index, otherwise return null for index name // Also this method only evaluates the if (globalSecondaryIndexName == null && attributeConditions != null && !attributeConditions.isEmpty()) { // Declare map of index names by attribute name which we will populate below - this will be used to determine which index to use if multiple indexes are applicable Map<String, String[]> indexNamesByAttributeName = new HashMap<String, String[]>(); // Declare map of attribute lists by index name which we will populate below - this will be used to determine whether we have an exact match index for specified attribute conditions MultiValueMap<String, String> attributeListsByIndexName = new LinkedMultiValueMap<String, String>(); // Populate the above maps for (Entry<String, String[]> indexNamesForPropertyNameEntry : entityInformation .getGlobalSecondaryIndexNamesByPropertyName().entrySet()) { String propertyName = indexNamesForPropertyNameEntry.getKey(); String attributeName = getAttributeName(propertyName); indexNamesByAttributeName.put(attributeName, indexNamesForPropertyNameEntry.getValue()); for (String indexNameForPropertyName : indexNamesForPropertyNameEntry.getValue()) { attributeListsByIndexName.add(indexNameForPropertyName, attributeName); }//from w ww. ja v a 2 s . co m } // Declare lists to store matching index names List<String> exactMatchIndexNames = new ArrayList<String>(); List<String> partialMatchIndexNames = new ArrayList<String>(); // Populate matching index name lists - an index is either an exact match ( the index attributes match all the specified criteria exactly) // or a partial match ( the properties for the specified criteria are contained within the property set for an index ) for (Entry<String, List<String>> attributeListForIndexNameEntry : attributeListsByIndexName .entrySet()) { String indexNameForAttributeList = attributeListForIndexNameEntry.getKey(); List<String> attributeList = attributeListForIndexNameEntry.getValue(); if (attributeList.containsAll(attributeConditions.keySet())) { if (attributeConditions.keySet().containsAll(attributeList)) { exactMatchIndexNames.add(indexNameForAttributeList); } else { partialMatchIndexNames.add(indexNameForAttributeList); } } } if (exactMatchIndexNames.size() > 1) { throw new RuntimeException( "Multiple indexes defined on same attribute set:" + attributeConditions.keySet()); } else if (exactMatchIndexNames.size() == 1) { globalSecondaryIndexName = exactMatchIndexNames.get(0); } else if (partialMatchIndexNames.size() > 1) { if (attributeConditions.size() == 1) { globalSecondaryIndexName = getFirstDeclaredIndexNameForAttribute(indexNamesByAttributeName, partialMatchIndexNames, attributeConditions.keySet().iterator().next()); } if (globalSecondaryIndexName == null) { globalSecondaryIndexName = partialMatchIndexNames.get(0); } } else if (partialMatchIndexNames.size() == 1) { globalSecondaryIndexName = partialMatchIndexNames.get(0); } } return globalSecondaryIndexName; }