List of usage examples for java.util Set toString
public String toString()
From source file:org.apache.sentry.policy.db.AbstractTestSimplePolicyEngine.java
@Test public void testDbAll() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(PERM_SERVER1_JUNIOR_ANALYST_ALL, PERM_SERVER1_CUSTOMERS_DB_CUSTOMERS_PARTIAL_SELECT)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getAllPrivileges(set("jranalyst"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.sentry.policy.db.AbstractTestSimplePolicyEngine.java
@Test public void testAnalyst() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(PERM_SERVER1_CUSTOMERS_SELECT, PERM_SERVER1_ANALYST_ALL, PERM_SERVER1_JUNIOR_ANALYST_READ)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getAllPrivileges(set("analyst"), ActiveRoleSet.ALL)).toString()); }
From source file:com.opengamma.integration.tool.marketdata.HtsSyncTool.java
private Set<String> filterClassifiers(Set<String> srcMasterClassifiers, Set<String> destMasterClassifiers) { Set<String> commonComponentNames = Sets.newLinkedHashSet(); commonComponentNames.addAll(srcMasterClassifiers); commonComponentNames.retainAll(destMasterClassifiers); if (getCommandLine().hasOption("classifiers")) { List<String> classifiersList = Arrays.asList(getCommandLine().getOptionValues("classifiers")); Set<String> classifiers = Sets.newHashSet(); classifiers.addAll(classifiersList); classifiers.removeAll(classifiers); if (classifiers.size() > 0) { System.err.println("Couldn't find classifiers: " + classifiers.toString() + ", skipping those"); }/*w w w . j a va 2 s . com*/ classifiers.clear(); classifiers.addAll(classifiersList); commonComponentNames.retainAll(classifiers); } return commonComponentNames; }
From source file:delfos.dataset.basic.item.ContentDatasetDefault.java
@Override public String toString() { Set<String> items = this.stream().map((item) -> "Item " + item.getId()) .collect(Collectors.toCollection(TreeSet::new)); return items.toString(); }
From source file:com.brennasoft.facebookdashclockextension.fbclient.NotificationsRequest.java
public NotificationsResponse executeWithApplicationFilter(Session session, Set<String> applicationTypes) { NotificationsResponse notificationsResponse = null; if (session.isOpened()) { Bundle parameters = new Bundle(); parameters.putString("q", q + " and app_id in " + applicationTypes.toString().replace('[', '(').replace(']', ')')); Request request = new Request(session, "/fql", parameters, HttpMethod.GET); Response response = request.executeAndWait(); FacebookRequestError error = response.getError(); if (error == null) { notificationsResponse = parseResponse(response); } else {/*from w w w . j a va 2s. c om*/ notificationsResponse = new NotificationsResponse(); } } return notificationsResponse; }
From source file:com.netflix.nicobar.core.persistence.ArchiveRepositoryTest.java
/** * Test insert, update, delete// w w w . j a va 2s .c om */ @Test public void testRoundTrip() throws Exception { ArchiveRepository repository = createRepository(); JarScriptArchive jarScriptArchive = new JarScriptArchive.Builder(testArchiveJarFile).build(); ModuleId testModuleId = TEST_MODULE_SPEC_JAR.getModuleId(); repository.insertArchive(jarScriptArchive); Map<ModuleId, Long> archiveUpdateTimes = repository.getDefaultView().getArchiveUpdateTimes(); long expectedUpdateTime = Files.getLastModifiedTime(testArchiveJarFile).toMillis(); assertEquals(archiveUpdateTimes, Collections.singletonMap(testModuleId, expectedUpdateTime)); // assert getScriptArchives Set<ScriptArchive> scriptArchives = repository.getScriptArchives(archiveUpdateTimes.keySet()); assertEquals(scriptArchives.size(), 1, scriptArchives.toString()); ScriptArchive scriptArchive = scriptArchives.iterator().next(); assertEquals(scriptArchive.getModuleSpec().getModuleId(), testModuleId); assertEquals(scriptArchive.getCreateTime(), expectedUpdateTime); // assert getArchiveSummaries List<ArchiveSummary> archiveSummaries = repository.getDefaultView().getArchiveSummaries(); assertEquals(archiveSummaries.size(), 1); ArchiveSummary archiveSummary = archiveSummaries.get(0); assertEquals(archiveSummary.getModuleId(), testModuleId); assertEquals(archiveSummary.getLastUpdateTime(), expectedUpdateTime); // assert getRepositorySummary RepositorySummary repositorySummary = repository.getDefaultView().getRepositorySummary(); assertNotNull(repositorySummary); assertEquals(repositorySummary.getArchiveCount(), 1); assertEquals(repositorySummary.getLastUpdated(), expectedUpdateTime); // advance the timestamp by 10 seconds and update expectedUpdateTime = expectedUpdateTime + 10000; Files.setLastModifiedTime(testArchiveJarFile, FileTime.fromMillis(expectedUpdateTime)); jarScriptArchive = new JarScriptArchive.Builder(testArchiveJarFile).build(); repository.insertArchive(jarScriptArchive); archiveUpdateTimes = repository.getDefaultView().getArchiveUpdateTimes(); assertEquals(archiveUpdateTimes, Collections.singletonMap(testModuleId, expectedUpdateTime)); // assert getScriptArchives scriptArchives = repository.getScriptArchives(archiveUpdateTimes.keySet()); assertEquals(scriptArchives.size(), 1, scriptArchives.toString()); scriptArchive = scriptArchives.iterator().next(); assertEquals(scriptArchive.getModuleSpec().getModuleId(), testModuleId); assertEquals(scriptArchive.getCreateTime(), expectedUpdateTime); // assert getArchiveSummaries archiveSummaries = repository.getDefaultView().getArchiveSummaries(); assertEquals(archiveSummaries.size(), 1); archiveSummary = archiveSummaries.get(0); assertEquals(archiveSummary.getModuleId(), testModuleId); assertEquals(archiveSummary.getLastUpdateTime(), expectedUpdateTime); // assert getRepositorySummary repositorySummary = repository.getDefaultView().getRepositorySummary(); assertNotNull(repositorySummary); assertEquals(repositorySummary.getArchiveCount(), 1); assertEquals(repositorySummary.getLastUpdated(), expectedUpdateTime); // delete module repository.deleteArchive(testModuleId); archiveUpdateTimes = repository.getDefaultView().getArchiveUpdateTimes(); assertTrue(archiveUpdateTimes.isEmpty(), archiveUpdateTimes.toString()); }
From source file:org.apache.sentry.policy.indexer.AbstractTestIndexerPolicyEngine.java
@Test public void testAnalyst() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(ANALYST_PURCHASES_WRITE, ANALYST_ANALYST1_ALL, ANALYST_JRANALYST1_ACTION_ALL, ANALYST_TMPINDEXER_WRITE, ANALYST_TMPINDEXER_READ)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPrivileges(set("analyst"), ActiveRoleSet.ALL)).toString()); }
From source file:org.openecomp.sdnc.sli.aai.AAIRequest.java
public static void setProperties(Properties props, AAIService aaiService) { AAIRequest.configProperties = props; AAIRequest.aaiService = aaiService;/*from w ww.j a va2s. c om*/ try { URL url = null; Bundle bundle = FrameworkUtil.getBundle(AAIServiceActivator.class); if (bundle != null) { BundleContext ctx = bundle.getBundleContext(); if (ctx == null) return; url = ctx.getBundle().getResource(AAIService.PATH_PROPERTIES); } else { url = aaiService.getClass().getResource("/aai-path.properties"); } InputStream in = url.openStream(); Reader reader = new InputStreamReader(in, "UTF-8"); Properties properties = new Properties(); properties.load(reader); LOG.info("loaded " + properties.size()); Set<String> keys = properties.stringPropertyNames(); int index = 0; Set<String> resourceNames = new TreeSet<String>(); for (String key : keys) { String[] tags = key.split("\\|"); for (String tag : tags) { if (!resourceNames.contains(tag)) { resourceNames.add(tag); tagValues.put(tag, Integer.toString(++index)); } } BitSet bs = new BitSet(256); for (String tag : tags) { String value = tagValues.get(tag); Integer bitIndex = Integer.parseInt(value); bs.set(bitIndex); } String path = properties.getProperty(key); LOG.info(String.format("bitset %s\t\t%s", bs.toString(), path)); bitsetPaths.put(bs, path); } LOG.info("loaded " + resourceNames.toString()); } catch (Exception e) { LOG.error("Caught exception", e); } }
From source file:gate.jape.functest.TestJape.java
/** Batch run */ public void testSimple() throws Exception { AnnotationCreator ac = new BaseAnnotationCreator() { @Override//from ww w. j ava 2 s . c o m public AnnotationSet createAnnots(Document doc) throws InvalidOffsetException { // defaultAS.add(new Long( 0), new Long( 2), "A",feat); add(2, 4, "A"); // defaultAS.add(new Long( 4), new Long( 6), "A",feat); // defaultAS.add(new Long( 6), new Long( 8), "A",feat); add(4, 6, "B"); // defaultAS.add(new Long(10), new Long(12), "B",feat); // defaultAS.add(new Long(12), new Long(14), "B",feat); // defaultAS.add(new Long(14), new Long(16), "B",feat); // defaultAS.add(new Long(16), new Long(18), "B",feat); add(6, 8, "C"); add(8, 10, "C"); // defaultAS.add(new Long(22), new Long(24), "C",feat); // defaultAS.add(new Long(24), new Long(26), "C",feat); return doc.getAnnotations(); } }; Set<Annotation> res = doTest("texts/doc0.html", "/jape/TestABC.jape", ac); Out.println(res); assertEquals(res.toString(), 3, res.size()); compareStartOffsets(res, 2, 2, 2); compareEndOffsets(res, 6, 8, 10); }
From source file:org.apache.pig.impl.util.avro.AvroStorageSchemaConversionUtilities.java
/** * Translates an Avro schema to a Resource Schema (for Pig). Internal method. * @param s The avro schema for which to determine the type * @param namesInStack Set of already defined object names * @param alreadyDefinedSchemas Map of schema names to resourceschema objects * @param allowRecursiveSchema controls whether to throw an error * if the schema is recursive/*from w ww.jav a 2 s . c om*/ * @throws IOException * @return the corresponding pig schema */ private static ResourceSchema avroSchemaToResourceSchema(final Schema s, final Set<Schema> schemasInStack, final Map<String, ResourceSchema> alreadyDefinedSchemas, final Boolean allowRecursiveSchema) throws IOException { ResourceSchema.ResourceFieldSchema[] resourceFields = null; switch (s.getType()) { case RECORD: if (schemasInStack.contains(s)) { if (allowRecursiveSchema) { break; // don't define further fields in the schema } else { throw new IOException("Pig found recursive schema definition while processing" + s.toString() + " encountered " + s.getFullName() + " which was already seen in this stack: " + schemasInStack.toString() + "\n"); } } schemasInStack.add(s); resourceFields = new ResourceSchema.ResourceFieldSchema[s.getFields().size()]; for (Field f : s.getFields()) { resourceFields[f.pos()] = fieldToResourceFieldSchema(f, schemasInStack, alreadyDefinedSchemas, allowRecursiveSchema); } schemasInStack.remove(s); break; default: // wrap in a tuple resourceFields = new ResourceSchema.ResourceFieldSchema[1]; Field f = new Schema.Field(s.getName(), s, s.getDoc(), null); resourceFields[0] = fieldToResourceFieldSchema(f, schemasInStack, alreadyDefinedSchemas, allowRecursiveSchema); } ResourceSchema rs = new ResourceSchema(); rs.setFields(resourceFields); return rs; }