List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:com.google.plus.wigwamnow.social.FacebookProvider.java
/** * Determines if the current user has authorized the app with the publish_stream permission. * //w w w . j a v a 2s . co m * @return true if the app is authorized to publish on behalf of the user. */ private boolean hasPublishPermissions() { Session session = Session.getActiveSession(); List<String> permissions = session.getPermissions(); return (permissions.containsAll(PERMISSIONS)); }
From source file:org.ejbca.core.model.era.RaCertificateSearchRequest.java
/** @return true if thisObject does contain whole other, but other does not contain whole this more narrow */ private boolean isMoreNarrow(final List<Integer> thisObject, final List<Integer> otherObject) { return thisObject.containsAll(otherObject) && !otherObject.containsAll(thisObject); }
From source file:org.ejbca.core.model.era.RaCertificateSearchRequest.java
/** @return true if thisObject does not contain whole other wider */ private boolean isWider(final List<Integer> thisObject, final List<Integer> otherObject) { return !thisObject.containsAll(otherObject); }
From source file:org.ensembl.healthcheck.testcase.eg_compara.AbstractControlledRows.java
protected boolean columnsAreSubset(final Connection testDbConn, final Connection masterconn, final String controlledTableToTest) { final List<String> testTableColumns = getColumnsOfTable(testDbConn, controlledTableToTest); final List<String> masterColumns = getColumnsOfTable(masterconn, controlledTableToTest); boolean masterHasAllNecessaryColumns = masterColumns.containsAll(testTableColumns); return masterHasAllNecessaryColumns; }
From source file:org.obiba.mica.study.service.IndividualStudyService.java
private List<String> populationsOrDceAffected(Study study, Study oldStudy, boolean withDceStartField) { if (oldStudy != null) { List<String> newDceUIDs = toListOfDceUids(study, withDceStartField); List<String> oldDceUIDs = toListOfDceUids(oldStudy, withDceStartField); boolean isChangeSignificant = newDceUIDs.size() <= oldDceUIDs.size() && !newDceUIDs.containsAll(oldDceUIDs); if (isChangeSignificant) { oldDceUIDs.removeAll(newDceUIDs); return oldDceUIDs; } else/* w ww . j av a2 s . co m*/ return null; } else return null; }
From source file:org.talend.designer.core.ui.editor.properties.controllers.EncodingTypeController.java
private void addEncodingType(IElementParameter encodingTypeParameter) { List<String> newEncodingTypes = Arrays.asList(new String[] { "ISO8859-1", "utf-16", "GB2312" }); String[] listItemsDisplayCodeName = encodingTypeParameter.getListItemsDisplayCodeName(); String[] listItemsdisplayName = encodingTypeParameter.getListItemsDisplayName(); Object[] listItemsValue = encodingTypeParameter.getListItemsValue(); List<String> newDisplayCodeName = new ArrayList<String>(); newDisplayCodeName.addAll(Arrays.asList(listItemsDisplayCodeName)); if (!newDisplayCodeName.containsAll(newEncodingTypes)) { newDisplayCodeName.remove(newDisplayCodeName.size() - 1); newDisplayCodeName.addAll(newEncodingTypes); newDisplayCodeName.add(listItemsDisplayCodeName[listItemsDisplayCodeName.length - 1]); encodingTypeParameter// ww w . j av a2 s . c om .setListItemsDisplayCodeName(newDisplayCodeName.toArray(new String[newDisplayCodeName.size()])); } List<String> newDisplayNames = new ArrayList<String>(); newDisplayNames.addAll(Arrays.asList(listItemsdisplayName)); if (!newDisplayNames.containsAll(newEncodingTypes)) { newDisplayNames.remove(newDisplayNames.size() - 1); newDisplayNames.addAll(newEncodingTypes); newDisplayNames.add(listItemsdisplayName[listItemsdisplayName.length - 1]); encodingTypeParameter .setListItemsDisplayName(newDisplayNames.toArray(new String[newDisplayNames.size()])); } List<Object> newValues = new ArrayList<Object>(); newValues.addAll(Arrays.asList(listItemsValue)); if (!newValues.containsAll(newEncodingTypes)) { newValues.remove(newValues.size() - 1); newValues.addAll(newEncodingTypes); newValues.add(listItemsValue[listItemsValue.length - 1]); encodingTypeParameter.setListItemsValue(newValues.toArray()); } }
From source file:com.dianping.wed.cache.redis.WeddingRedisServiceImplTest.java
private void testHash() { //************************** Hash ********************************// //key ?/*from ww w. j av a 2 s . co m*/ weddingRedisService.del(key); long hSet = weddingRedisService.hSet(key, "a", "0"); Assert.assertTrue(hSet == 1); hSet = weddingRedisService.hSet(key, "a", "1"); Assert.assertTrue(hSet == 0); String hGet = weddingRedisService.hGet(key, "a"); Assert.assertTrue(hGet.equals("1")); boolean hExists = weddingRedisService.hExists(key, "a"); Assert.assertTrue(hExists); long hDel = weddingRedisService.hDel(key, "a"); Assert.assertTrue(hDel == 1); hExists = weddingRedisService.hExists(key, "a"); Assert.assertTrue(!hExists); weddingRedisService.hSet(key, "a", "1"); weddingRedisService.hSet(key, "b", "2"); weddingRedisService.hSet(key, "c", "3"); Map<String, String> hGetAll = weddingRedisService.hGetAll(key); Assert.assertTrue(hGetAll.size() == 3); long hLen = weddingRedisService.hLen(key); Assert.assertTrue(hLen == 3); long hIncrBy = weddingRedisService.hIncrBy(key, "c", 1); Assert.assertTrue(hIncrBy == 4); Set<String> hKeys = weddingRedisService.hKeys(key); Assert.assertTrue(hKeys.size() == 3); List<String> keys = new ArrayList<String>(); keys.add("a"); keys.add("b"); keys.add("c"); Assert.assertTrue(hKeys.containsAll(keys)); List<String> hVals = weddingRedisService.hVals(key); List<String> vals = new ArrayList<String>(); keys.add("1"); keys.add("2"); keys.add("4"); Assert.assertTrue(hVals.containsAll(vals)); Map<String, String> kvs = new HashMap<String, String>(); kvs.put("1231", "1231"); kvs.put("1232", "1232"); kvs.put("1233", "1233"); kvs.put("1234", "1234"); String result = weddingRedisService.hMSet(key, kvs); Assert.assertTrue(result.equalsIgnoreCase("ok")); List<String> resultList = weddingRedisService.hMGet(key, "1231", "1232", "1233", "1234"); Assert.assertTrue(resultList.size() == 4); Assert.assertTrue(resultList.get(0).equalsIgnoreCase("1231")); }
From source file:com.tesora.dve.tools.DVEAnalyzerCLI.java
public static Map<String, String> compareTemplates(final Template baseTemplate, final Template comparedTemplate) { final Comparator<TableTemplateType> orderByMatch = new Comparator<TableTemplateType>() { @Override/*from www . j a v a 2s . c o m*/ public int compare(TableTemplateType a, TableTemplateType b) { if (a.getMatch().equals(".*")) { return 0; } return a.getMatch().compareTo(b.getMatch()); } }; final Set<TableTemplateType> baseItems = new TreeSet<TableTemplateType>(orderByMatch); final Set<TableTemplateType> comparedItems = new TreeSet<TableTemplateType>(orderByMatch); baseItems.addAll(baseTemplate.getTabletemplate()); comparedItems.addAll(comparedTemplate.getTabletemplate()); final Set<TableTemplateType> addedItems = getDifference(comparedItems, baseItems, orderByMatch); final Set<TableTemplateType> removedItems = getDifference(baseItems, comparedItems, orderByMatch); final Set<TableTemplateType> intersectionItems = getIntersection(comparedItems, baseItems, orderByMatch); final String arrow = " -> "; final String columnSeparator = ", "; final Map<String, String> results = new TreeMap<String, String>(); for (final TableTemplateType item : intersectionItems) { final TableTemplateType baseItem = getFromCollection(baseItems, item); final TableTemplateType comparedItem = getFromCollection(comparedItems, item); final ModelType baseModel = baseItem.getModel(); final ModelType itemModel = comparedItem.getModel(); if (!baseModel.equals(itemModel)) { results.put(item.getMatch(), baseModel.value().concat(arrow).concat(itemModel.value())); } else { if (baseModel.equals(ModelType.RANGE)) { final List<String> baseColumns = baseItem.getColumn(); final List<String> itemColumns = comparedItem.getColumn(); if (!baseColumns.containsAll(itemColumns) || !itemColumns.containsAll(baseColumns)) { results.put(item.getMatch(), ("(" + ModelType.RANGE + ") <") .concat(StringUtils.join(baseColumns, columnSeparator)).concat(arrow) .concat(StringUtils.join(itemColumns, columnSeparator)).concat(">")); continue; } } results.put(item.getMatch(), "MATCH"); } } for (final TableTemplateType item : addedItems) { results.put(item.getMatch(), "ADDED"); } for (final TableTemplateType item : removedItems) { results.put(item.getMatch(), "REMOVED"); } return results; }
From source file:com.boundary.sdk.event.script.ScriptRouteBuilderTest.java
@Test public void testSyslogToEvent() throws InterruptedException { out.expectedMessageCount(1);// w w w . ja v a2 s .c o m in.sendBodyAndHeaders(this.syslogMessageEvent, setScriptHeader("classpath:META-INF/js/lib/syslog-to-event.js")); out.assertIsSatisfied(); List<Exchange> exchanges = out.getExchanges(); assertEquals("check exchange count", 1, exchanges.size()); Exchange exchange = exchanges.get(0); Message message = exchange.getIn(); RawEvent e = message.getBody(RawEvent.class); assertNotNull("check event for not null", e); SyslogMessageEvent sme = this.syslogMessageEvent; assertEquals("check facility property", this.syslogMessageEvent.getFacility(), e.getProperties().get("facility")); assertTrue("check facility tag exists", e.getTags().contains(sme.getFacility())); assertEquals("check hostname property", sme.getHostname(), e.getProperties().get("hostname")); assertTrue("check hostname tag exists", e.getTags().contains(sme.getHostname())); assertEquals("check source ref", sme.getHostname(), e.getSource().getRef()); assertEquals("check source type", "host", e.getSource().getType()); assertEquals("check message", sme.getLogMessage(), e.getMessage()); assertEquals("check message property", sme.getLogMessage(), e.getProperties().get("message")); assertEquals("check remote address property", sme.getRemoteAddress(), e.getProperties().get("remote_address")); assertTrue("check remote address tag exists", e.getTags().contains(sme.getRemoteAddress())); assertEquals("check severity", Severity.CRITICAL, e.getSeverity()); assertEquals("check status", Status.OPEN, e.getStatus()); assertEquals("check number of fingerprint fields", 3, e.getFingerprintFields().size()); List<String> fp = new ArrayList<String>(); fp.add("hostname"); fp.add("facility"); fp.add("message"); assertTrue("check fingerprint fields in event", e.getFingerprintFields().containsAll(fp)); assertTrue("check fingerprint fields in array", fp.containsAll(e.getFingerprintFields())); assertEquals("check createdAt", this.now, e.getCreatedAt()); assertEquals("check title", "Syslog message from: " + sme.getHostname(), e.getTitle()); assertEquals("check sender ref", "Syslog", e.getSender().getRef()); assertEquals("check sender type", "Boundary Event SDK", e.getSender().getType()); }
From source file:org.apache.nifi.toolkit.tls.util.TlsHelperTest.java
@Test public void testShouldIncludeSANFromCSR() throws Exception { // Arrange/* w w w. j a v a 2s . co m*/ final List<String> SAN_ENTRIES = Arrays.asList("127.0.0.1", "nifi.nifi.apache.org"); final String SAN = StringUtils.join(SAN_ENTRIES, ","); final int SAN_COUNT = SAN_ENTRIES.size(); final String DN = "CN=localhost"; KeyPair keyPair = keyPairGenerator.generateKeyPair(); logger.info("Generating CSR with DN: " + DN); // Act JcaPKCS10CertificationRequest csrWithSan = TlsHelper.generateCertificationRequest(DN, SAN, keyPair, TlsConfig.DEFAULT_SIGNING_ALGORITHM); logger.info("Created CSR with SAN: " + SAN); String testCsrPem = TlsHelper.pemEncodeJcaObject(csrWithSan); logger.info("Encoded CSR as PEM: " + testCsrPem); // Assert String subjectName = csrWithSan.getSubject().toString(); logger.info("CSR Subject Name: " + subjectName); assert subjectName.equals(DN); List<String> extractedSans = extractSanFromCsr(csrWithSan); assert extractedSans.size() == SAN_COUNT; List<String> formattedSans = SAN_ENTRIES.stream().map(s -> "DNS: " + s).collect(Collectors.toList()); assert extractedSans.containsAll(formattedSans); }