List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:com.nexmo.client.auth.NexmoUnacceptableAuthException.java
private String generateErrorMessage() { SortedSet<String> availableTypes = new TreeSet<>(); for (AuthMethod auth : this.availableAuths) { availableTypes.add(auth.getClass().getSimpleName()); }/*w w w.j a v a 2 s . co m*/ SortedSet<String> acceptableTypes = new TreeSet<>(); for (Class klass : this.acceptableAuthClasses) { acceptableTypes.add(klass.getSimpleName()); } return String.format( "No acceptable authentication type could be found. Acceptable types are: %s. Supplied " + "types " + "were: %s", StringUtils.join(acceptableTypes, ", "), StringUtils.join(availableTypes, ", ")); }
From source file:net.praqma.jenkins.rqm.unit.RqmTestCase.java
public TestPlan defaultTestPlan() { TestPlan plan = new TestPlan("TestPlan1"); plan.setRqmObjectResourceUrl("testplan:tp1"); TestSuite suite = new TestSuite(null, "TestSuite1"); suite.setRqmObjectResourceUrl("testsuite:ts1"); TestCase tc = new TestCase("TestCase1"); tc.setRqmObjectResourceUrl("testcase:tc1"); SortedSet<TestCase> cases = new TreeSet<TestCase>(); cases.add(tc); suite.setTestcases(cases);//w w w .j a va 2 s .co m SortedSet<TestSuite> suites = new TreeSet<TestSuite>(); suites.add(suite); plan.setTestSuites(suites); return plan; }
From source file:com.opencredo.portlet.MyBooksController.java
@RequestMapping("EDIT") public void myEditBooksAction(ActionRequest request, PortletPreferences prefs, @RequestParam("what") String what, @RequestParam("book") Integer id) { Book book = bookService.getBook(id); if (book == null) return;//from w ww . j av a2 s . c o m SortedSet<Book> myBooks = loadMyBooks(prefs); if (what.equals("add")) { myBooks.add(book); } else if (what.equals("remove")) { myBooks.remove(book); } storeMyBooks(prefs, myBooks); }
From source file:io.seqware.pipeline.engines.whitestar.Persistence.java
public synchronized WorkflowRun readWorkflowRun() { try {/*from w w w . j a v a 2s . co m*/ Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .setPrettyPrinting().create(); String workflowRunString = FileUtils.readFileToString(new File(persistDir, WORKFLOW_RUN_FILENAME)); String workflowString = FileUtils.readFileToString(new File(persistDir, WORKFLOW_FILENAME)); WorkflowRun workflowRun = gson.fromJson(workflowRunString, WorkflowRun.class); Workflow workflow = gson.fromJson(workflowString, Workflow.class); workflowRun.setWorkflow(workflow); SortedSet<WorkflowRun> runs = new TreeSet<>(); runs.add(workflowRun); workflow.setWorkflowRuns(runs); // load into persistence store if needed Metadata metadata = MetadataFactory.get(ConfigTools.getSettings()); if (metadata instanceof MetadataInMemory) { MetadataInMemory mim = (MetadataInMemory) metadata; mim.loadEntity(workflow); mim.loadEntity(workflowRun); } return workflowRun; } catch (IOException ex) { Log.stdoutWithTime("Unable to read workflowrun state"); rethrow(ex); } return null; }
From source file:net.solarnetwork.central.dras.dao.ibatis.test.IbatisEventTargetsDaoTest.java
/** * Test store new EventTargets./*www . ja va2 s . c o m*/ */ @Test public void insertEventTargets() { setupTestEventRule(); EventTargets eventTargets = new EventTargets(); eventTargets.setEventRuleId(TEST_EVENT_RULE_ID); eventTargets.setOverallDuration(new Duration(1000 * 60 * 60)); SortedSet<EventTarget> targets = new TreeSet<EventTarget>(); targets.add(new EventTarget(new Duration(1000 * 60 * 15), 1.0)); targets.add(new EventTarget(new Duration(1000 * 60 * 30), 2.0)); targets.add(new EventTarget(new Duration(1000 * 60 * 45), 3.0)); eventTargets.setTargets(targets); logger.debug("Inserting new EventTargets: " + eventTargets); Long id = eventTargetsDao.store(eventTargets); assertNotNull(id); EventTargets entity = eventTargetsDao.get(id); validateEventTargets(eventTargets, entity); lastEventTargetsId = id; }
From source file:io.seqware.pipeline.engines.whitestar.Persistence.java
public synchronized void persistState(int swid, SortedSet<String> completedJobs) { try {// ww w. ja va 2s .co m // write state of workflow run Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .setPrettyPrinting().create(); Metadata ws = MetadataFactory.get(ConfigTools.getSettings()); WorkflowRun workflowRun = ws.getWorkflowRunWithWorkflow(String.valueOf(swid)); Workflow workflow = workflowRun.getWorkflow(); workflowRun.setWorkflow(null); workflow.setWorkflowRuns(null); if (workflow.getWorkflowParams() != null) { for (WorkflowParam param : workflow.getWorkflowParams()) { param.setWorkflow(null); } } // ugly, need to avoid circular reference before serialization FileUtils.write(new File(persistDir, WORKFLOW_RUN_FILENAME), gson.toJson(workflowRun)); FileUtils.write(new File(persistDir, WORKFLOW_FILENAME), gson.toJson(workflow)); FileUtils.write(new File(persistDir, STATE_FILENAME), gson.toJson(completedJobs)); workflowRun.setWorkflow(workflow); SortedSet<WorkflowRun> set = new TreeSet<>(); set.add(workflowRun); workflow.setWorkflowRuns(set); if (workflow.getWorkflowParams() != null) { for (WorkflowParam param : workflow.getWorkflowParams()) { param.setWorkflow(workflow); } } } catch (IOException ex) { Log.stdoutWithTime("Unable to write workflowrun state"); rethrow(ex); } }
From source file:org.sventon.cache.direntrycache.DirEntryCacheUpdaterTest.java
@Test public void testUpdate() throws Exception { final RepositoryService serviceMock = mock(RepositoryService.class); assertEquals(0, entryCache.getSize()); final List<LogEntry> logEntries = new ArrayList<LogEntry>(); final SortedSet<ChangedPath> changedPaths1 = new TreeSet<ChangedPath>(); changedPaths1.add(new ChangedPath("/file1.java", null, -1, ChangeType.MODIFIED)); changedPaths1.add(new ChangedPath("/file2.abc", null, -1, ChangeType.ADDED)); changedPaths1.add(new ChangedPath("/trunk/file3.def", null, -1, ChangeType.REPLACED)); logEntries.add(createLogEntry(123, "author", new Date(), "Log message for revision 123.", changedPaths1)); final SortedSet<ChangedPath> changedPaths2 = new TreeSet<ChangedPath>(); changedPaths2.add(new ChangedPath("/branch", "/trunk", 123, ChangeType.ADDED)); changedPaths2.add(new ChangedPath("/trunk/file3.def", null, -1, ChangeType.DELETED)); logEntries.add(createLogEntry(124, "author", new Date(), "Log message for revision 124.", changedPaths2)); final ConfigDirectory configDirectory = TestUtils.getTestConfigDirectory(); configDirectory.setCreateDirectories(false); final MockServletContext servletContext = new MockServletContext(); servletContext.setContextPath("sventon-test"); configDirectory.setServletContext(servletContext); final Application application = new Application(configDirectory); when(serviceMock.getLatestRevision(null)).thenReturn(124L); when(serviceMock.getEntryInfo(null, "/file1.java", 123)) .thenReturn(new DirEntry("/", "file1.java", "author", new Date(), DirEntry.Kind.FILE, 123, 12345)); when(serviceMock.getEntryInfo(null, "/file2.abc", 123)) .thenReturn(new DirEntry("/", "file2.abc", "author", new Date(), DirEntry.Kind.FILE, 123, 12345)); when(serviceMock.getEntryInfo(null, "/trunk/file3.def", 123)).thenReturn( new DirEntry("/trunk", "file3.def", "author", new Date(), DirEntry.Kind.FILE, 123, 12345)); when(serviceMock.getEntryInfo(null, "/branch", 124)) .thenReturn(new DirEntry("/", "branch", "author", new Date(), DirEntry.Kind.DIR, 123, 12345)); when(serviceMock.list(null, "/branch/", 124)) .thenReturn(new DirList(Collections.<DirEntry>emptyList(), new Properties())); when(serviceMock.getEntryInfo(null, "/trunk/file3.def", 123)).thenReturn( new DirEntry("/trunk", "file3.def", "author", new Date(), DirEntry.Kind.FILE, 123, 12345)); final RepositoryName repositoryName = new RepositoryName("defaultsvn"); final RevisionUpdate revisionUpdate = new RevisionUpdate(repositoryName, logEntries, false); final DirEntryCacheUpdater cacheUpdater = new DirEntryCacheUpdater(null, application); cacheUpdater.setRepositoryService(serviceMock); cacheUpdater.updateInternal(entryCache, null, revisionUpdate); Thread.sleep(500L); // TODO: Get rid of this! assertEquals(4, entryCache.getSize()); }
From source file:com.sonatype.security.ldap.AbstractMockLdapConnectorTest.java
protected MockLdapConnector buildBackupMockServer(String serverId) { SortedSet<String> groupIds = new TreeSet<String>(); groupIds.add("alpha"); groupIds.add("beta"); SortedSet<LdapUser> users = new TreeSet<LdapUser>(); LdapUser ehearn = new LdapUser(); ehearn.setDn("uid=ehearn,ou=people,o=sonatype"); ehearn.setRealName("Eula Hearn"); ehearn.setEmail("ehearn@sonatype.com"); ehearn.setMembership(new HashSet<String>()); ehearn.getMembership().add("alpha"); ehearn.setPassword("ehearn123"); ehearn.setUsername("ehearn"); users.add(ehearn);//from w w w . j a va2 s . c om LdapUser jgoodman = new LdapUser(); jgoodman.setDn("uid=jgoodman,ou=people,o=sonatype"); jgoodman.setRealName("Joseph M. Goodman"); jgoodman.setEmail("jgoodman@sonatype.com"); jgoodman.setMembership(new HashSet<String>()); jgoodman.getMembership().add("alpha"); jgoodman.getMembership().add("beta"); jgoodman.setPassword("jgoodman123"); jgoodman.setUsername("jgoodman"); users.add(jgoodman); return new MockLdapConnector(serverId, users, groupIds); }
From source file:fi.smaa.libror.PerformanceMatrix.java
private void initializeLevelIndices() { for (int i = 0; i < getNrCrit(); i++) { SortedSet<Double> s = new TreeSet<Double>(); for (Double d : levels[i].toArray()) { s.add(d); }// ww w. j a va 2 s . co m Double[] arr = s.toArray(new Double[0]); int[] colIndices = new int[getNrAlts()]; for (int j = 0; j < getNrAlts(); j++) { for (int k = 0; k < arr.length; k++) { if (arr[k] == matrix.getEntry(j, i)) { colIndices[j] = k; break; } } } levelIndices.add(colIndices); } }
From source file:sample.portlet.MyBooksEditController.java
@Override protected void handleActionRequestInternal(ActionRequest request, ActionResponse response) throws Exception { String what = request.getParameter("what"); if (what == null) return;// w w w. j a va 2 s .c o m Integer id = Integer.valueOf(request.getParameter("book")); if (id == null) return; Book book = bookService.getBook(id); if (book == null) return; SortedSet<Book> myBooks = loadMyBooks(request); if (what.equals("add")) { myBooks.add(book); } else if (what.equals("remove")) { myBooks.remove(book); } storeMyBooks(request, myBooks); }