List of usage examples for java.util Set toString
public String toString()
From source file:com.facebook.buck.java.JarDirectoryStepTest.java
private void assertZipFileCountIs(int expected, Path zip) throws IOException { Set<String> fileNames = getFileNames(zip); assertEquals(fileNames.toString(), expected, fileNames.size()); }
From source file:org.g_node.srv.CliOptionServiceTest.java
/** * Test option letter, long option text, description, use of alternative description as well as * isRequired, hasArgument and hasArguments state of the output format CLI option. * @throws Exception/* ww w .j a v a 2 s .c om*/ */ @Test public void testOutFormatOpt() throws Exception { final String shortOpt = "f"; final String longOpt = "out-format"; final Set formats = Collections.singleton("theOnlyFormat"); final String desc = String.join("", "Optional: Format of the report file. Default setting is the CSV format.", "\nAvailable output formats: ", formats.toString()); final String altDesc = "Different message."; final Boolean isRequired = false; final Boolean hasArgument = true; final Boolean hasArguments = false; final Option defaultOption = CliOptionService.getOutFormatOption("", formats); this.assertOption(defaultOption, shortOpt, longOpt, desc, isRequired, hasArgument, hasArguments); final Option altDescOption = CliOptionService.getOutFormatOption(altDesc, formats); this.assertOption(altDescOption, shortOpt, longOpt, altDesc, isRequired, hasArgument, hasArguments); }
From source file:org.slc.sli.api.security.context.validator.StaffToStudentValidator.java
@Override public Set<String> validate(String entityType, Set<String> studentIds) throws IllegalStateException { LOG.debug(">>>StaffToStudentValidator.validate(?)", entityType); LOG.debug(" studentIds: {}", (studentIds == null) ? "null" : studentIds.toString()); if (!areParametersValid(EntityNames.STUDENT, entityType, studentIds)) { LOG.debug(" !areParametersValid"); return new HashSet<String>(); }//from w w w. jav a 2 s.co m return validateStaffToStudentContextThroughSharedEducationOrganization(studentIds); }
From source file:org.apache.sentry.policy.sqoop.AbstractTestSqoopPolicyEngine.java
@Test public void testDeveloper() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(OPERATOR_JDBC_CONNECTORS_READ, OPERATOR_HDFS_CONNECTORS_READ, OPERATOR_KAFKA_CONNECTORS_READ, OPERATOR_KITE_CONNECTORS_READ, ANALYST_JOBS_ALL, ANALYST_LINKS_ALL)); Assert.assertEquals(expected.toString(), Sets.newTreeSet(policy.getPrivileges(set("developer"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.sentry.provider.file.AbstractTestSimplePolicyEngine.java
@Test public void testManager() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(PERM_SERVER1_CUSTOMERS_SELECT, PERM_SERVER1_ANALYST_ALL, PERM_SERVER1_JUNIOR_ANALYST_ALL, PERM_SERVER1_JUNIOR_ANALYST_READ, PERM_SERVER1_CUSTOMERS_DB_CUSTOMERS_PARTIAL_SELECT)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPermissions(authorizables, list("manager")).values()).toString()); }
From source file:org.apache.sentry.policy.indexer.AbstractTestIndexerPolicyEngine.java
@Test public void testManager() 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, JRANALYST_JRANALYST1_ALL, JRANALYST_PURCHASES_PARTIAL_READ)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPrivileges(set("manager"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.storm.container.cgroup.CgroupManager.java
public void releaseResourcesForWorker(String workerId) { CgroupCommon workerGroup = new CgroupCommon(workerId, hierarchy, this.rootCgroup); try {/* w ww. j a va 2 s . c o m*/ Set<Integer> tasks = workerGroup.getTasks(); if (!tasks.isEmpty()) { throw new Exception("Cannot correctly showdown worker CGroup " + workerId + "tasks " + tasks.toString() + " still running!"); } this.center.deleteCgroup(workerGroup); } catch (Exception e) { LOG.error("Exception thrown when shutting worker {} Exception: {}", workerId, e); } }
From source file:org.apache.sentry.policy.db.AbstractTestSimplePolicyEngine.java
@Test public void testManager() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(PERM_SERVER1_CUSTOMERS_SELECT, PERM_SERVER1_ANALYST_ALL, PERM_SERVER1_JUNIOR_ANALYST_ALL, PERM_SERVER1_JUNIOR_ANALYST_READ, PERM_SERVER1_CUSTOMERS_DB_CUSTOMERS_PARTIAL_SELECT)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getAllPrivileges(set("manager"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.sentry.policy.search.AbstractTestSearchPolicyEngine.java
@Test public void testManager() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(ANALYST_PURCHASES_UPDATE, ANALYST_ANALYST1_ALL, ANALYST_JRANALYST1_ACTION_ALL, ANALYST_TMPCOLLECTION_UPDATE, ANALYST_TMPCOLLECTION_QUERY, JRANALYST_JRANALYST1_ALL, JRANALYST_PURCHASES_PARTIAL_QUERY)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPrivileges(set("manager"), ActiveRoleSet.ALL)).toString()); }
From source file:ubic.pubmedgate.resolve.focusedAnalysis.MapNIFConnectionRegions.java
public void populate() throws Exception { MakeLexiconRDFModel lexiconModel = new MakeLexiconRDFModel(); if (useNN) {//from w ww . j av a 2s .c o m lexiconModel.addNN2007Nodes(); lexiconModel.addNN2010Nodes(); } else { lexiconModel.addNIFSTDNodes(); } // add evaluations boolean reason = true; ResolutionRDFModel resolutionModel = new ResolutionRDFModel(lexiconModel.getModel(), reason); resolutionModel.loadManualMatches(); resolutionModel.loadManualEvaluations(); Set<Resource> NIFConcepts; if (useNN) { NIFConcepts = resolutionModel.getNNConcepts(); } else { NIFConcepts = resolutionModel.getNIFSTDConcepts(); } Set<Resource> allTerms = resolutionModel.getTerms(); // for speed RDFResolver resolver; // resolver = new BagOfStemsRDFMatcher( resolutionModel.getTerms() ); resolver = new SimpleMappingRDFMatcher(resolutionModel.getTerms()); resolver.addMentionEditor(new DirectionSplittingMentionEditor()); resolver.addMentionEditor(new HemisphereStripMentionEditor()); resolver.addMentionEditor(new BracketRemoverMentionEditor()); resolver.addMentionEditor(new OfTheRemoverMentionEditor()); resolver.addMentionEditor(new CytoPrefixMentionEditor()); resolver.addMentionEditor(new RegionSuffixRemover()); // resolver.addMentionEditor( new DirectionRemoverMentionEditor() ); // resolver.addMentionEditor( new NucleusOfTheRemoverMentionEditor() ); // resolver.addMentionEditor( new DirectionRemoverMentionEditor() ); int resolved = 0; // start a spreadsheet int row = 1; int count = 0; CSVReader reader = new CSVReader(new FileReader(inFilename), '\t'); List<String[]> lines = reader.readAll(); // first line is header lines.remove(0); StopWatch watch = new StopWatch(); watch.start(); int rejectedMatches = 0; int skipped = 0; for (String[] line : lines) { boolean badregioname = false; String source = line[0]; String regionName = line[2]; if (regionName.equals("(null)") || regionName.equals("")) { log.info("Skipping on null or empty name"); badregioname = true; } if (source.equals("CoCoMac")) { // log.info( regionName ); if (regionName.contains(":")) { regionName = regionName.substring(regionName.indexOf(':') + 2); } else { log.info("missing colon"); badregioname = true; } // log.info( regionName ); } Set<Resource> regionResolves; if (badregioname) { regionResolves = new HashSet<Resource>(); regionName = ""; } else { regionResolves = resolutionModel.resolveToTerms(regionName, resolver, allTerms); } long t = lines.size() / (1 + count) * watch.getTime() / 1000 / 60; log.info(regionName + " " + count++ + " of " + lines.size() + " Time:" + watch.getTime() + " Remaining:" + t + " mins"); // if ( count > 50 ) break; StringToStringSetMap URItoTerms = new StringToStringSetMap(); Set<Resource> allResolvedConcepts = new HashSet<Resource>(); // deal with more than one way to resolve it, condense the synonyms to concept mappings for (Resource resolvedTerm : regionResolves) { Set<Resource> concepts = resolutionModel.getConceptsFromTerms(resolvedTerm, NIFConcepts); for (Resource regionConcept : concepts) { if (resolutionModel.rejected(resolvedTerm, regionConcept)) { log.info("Rejected match"); rejectedMatches++; continue; } allResolvedConcepts.add(regionConcept); URItoTerms.put(regionConcept.getURI(), JenaUtil.getLabel(resolvedTerm)); } } if (allResolvedConcepts.isEmpty()) { ExcelUtil.setValue(spreadsheet, row, schema.getPosition("database"), source); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("con_from_abb"), line[1]); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("con_from"), line[2]); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("RegionName"), regionName); row++; } else { resolved++; // for ( Resource resolvedTerm : regionResolves ) { // Set<Resource> concepts = resolutionModel.getConceptsFromTerms( resolvedTerm, NIFConcepts ); for (Resource regionConcept : allResolvedConcepts) { ExcelUtil.setValue(spreadsheet, row, schema.getPosition("database"), source); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("con_from_abb"), line[1]); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("con_from"), line[2]); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("RegionName"), regionName); Set<String> matchedTerms = URItoTerms.get(regionConcept.getURI()); String matchedTermsString = matchedTerms.toString(); matchedTermsString = matchedTermsString.substring(1, matchedTermsString.length() - 1); // comas are bad idea ExcelUtil.setValue(spreadsheet, row, schema.getPosition("MatchedTerm"), matchedTermsString); String regionConceptLabel = JenaUtil.getLabel(regionConcept); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NIFSTDLabel"), regionConceptLabel); boolean exactMatch = false; for (String termString : matchedTerms) { if (regionName.equalsIgnoreCase(termString)) { exactMatch = true; break; } } ExcelUtil.setValue(spreadsheet, row, schema.getPosition("ExactMatch"), exactMatch + ""); ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NIFSTDURI"), regionConcept.getURI()); row++; } } } log.info("Rejected matches:" + rejectedMatches); }