List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.CoveragePatternTest.java
@Test public void testAddLine() throws Exception { final SortedSet<Integer> lines = new TreeSet<>(); lines.add(1); lines.add(3);//from w ww . j a va 2s . co m lines.add(5); final CoveragePattern pattern = new CoveragePattern("resourcePattern", lines); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 3, full.size()); Assert.assertTrue("SortedSet must contain line 1", full.contains(1)); Assert.assertTrue("SortedSet must contain line 3", full.contains(3)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); }
From source file:no.dusken.aranea.model.LoginDetails.java
/** * Returns the authorities granted to the user. Cannot return <code>null</code>. * * @return the authorities, sorted by natural key (never <code>null</code>) *///from w w w .ja v a 2 s . co m public Collection<GrantedAuthority> getAuthorities() { SortedSet<GrantedAuthority> sorter = new TreeSet<GrantedAuthority>(); for (Role r : getRoles()) { sorter.add(r); } return sorter; }
From source file:org.shredzone.cilla.ws.assembler.PictureAssembler.java
@Override public void merge(PictureDto dto, Picture entity) throws CillaServiceException { super.merge(dto, entity); entity.setCreateDate(dto.getCreateDate()); entity.setCreateTimeZone(dto.getCreateTimeZone()); entity.setCreateTimeDefinition(dto.getCreateTimeDefinition()); entity.getThread().setCommentable(dto.isCommentable()); if (dto.getCaption() != null && dto.getCaptionFormat() != null) { entity.setCaption(new FormattedText(dto.getCaption(), dto.getCaptionFormat())); } else {// w w w .j ava 2 s . c o m entity.setCaption(null); } if (dto.getLongitude() != null && dto.getLatitude() != null) { Geolocation gl = new Geolocation(); gl.setLongitude(dto.getLongitude()); gl.setLatitude(dto.getLatitude()); gl.setAltitude(dto.getAltitude()); entity.setLocation(gl); } else { entity.setLocation(null); } SortedSet<Tag> tagSet = entity.getTags(); tagSet.clear(); dto.getTags().stream().map(tagDao::fetchOrCreate).forEach(tag -> tagSet.add(tag)); }
From source file:am.ik.categolj2.domain.repository.entry.EntryRepositoryTest.java
@Test @Rollback(false)//from ww w. j av a 2 s .com @Transactional public void testSave() { DateTime now = new DateTime(); String user = null; Entry entry = new Entry(null, "hoge!", "???", "html", null, true, null, Sets.newHashSet(new Tag("Java"), new Tag("Spring Boot"))); entry.setCreatedBy(user); entry.setCreatedDate(now); entry.setLastModifiedBy(user); entry.setLastModifiedDate(now); entryRepository.saveAndFlush(entry); assertThat(entry.getEntryId(), is(notNullValue())); System.out.println(entry); int order = 1; Category c1 = new Category(entry.getEntryId(), order++, "Programmming"); Category c2 = new Category(entry.getEntryId(), order++, "Java"); Category c3 = new Category(entry.getEntryId(), order++, "org"); Category c4 = new Category(entry.getEntryId(), order++, "springframework"); Category c5 = new Category(entry.getEntryId(), order++, "core"); SortedSet<Category> category = new TreeSet<Category>(); // added randomly category.add(c1); category.add(c2); category.add(c3); category.add(c4); category.add(c5); categoryRepository.save(category); }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testAddLine() throws Exception { final SortedSet<Integer> lines = new TreeSet<>(); lines.add(1); lines.add(3);/*from w ww. j a v a 2 s. c om*/ lines.add(5); final IssuePattern pattern = new IssuePattern("resourcePattern", "rulePattern", lines); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 3, full.size()); Assert.assertTrue("SortedSet must contain line 1", full.contains(1)); Assert.assertTrue("SortedSet must contain line 3", full.contains(3)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); }
From source file:gov.nih.nci.firebird.service.registration.AbstractPdfForm1572GeneratorTest.java
private void addOverflowingOrganizations(SortedSet<Organization> organizations) { for (int i = 0; i < 3; i++) { organizations.add(OrganizationFactory.getInstance().create()); }// ww w. j a v a 2 s . com }
From source file:com.cloudbees.demo.beesshop.product.ProductRepository.java
/** * @param name/*from w w w . java2s . c om*/ * @return */ public Collection<Product> find(@Nullable String name) { SortedSet<Product> result = new TreeSet<Product>(); for (Product product : products.values()) { if (name == null && name == null) { result.add(product); } if (StringUtils.hasLength(name)) { if (product.getName().toLowerCase().contains(name.toLowerCase())) { result.add(product); break; } } } return result; }
From source file:com.erinors.hpb.server.handler.SortedSetHandler.java
@Override public Object clone(CloningContext context, Object object) { if (!(object instanceof SortedSet)) { return null; }//from w ww. j av a2 s. co m SortedSet<Object> source = (SortedSet<Object>) object; SortedSet<Object> result; if (source instanceof PersistentSortedSet && !((PersistentSortedSet) source).wasInitialized()) { result = new UninitializedPersistentSortedSet<Object>(source.comparator()); context.addProcessedObject(object, result); } else { SortedSet<Object> set = new TreeSet<Object>(source.comparator()); context.addProcessedObject(object, set); for (Object element : source) { set.add(context.clone(element)); } result = set; } return result; }
From source file:com.erinors.hpb.server.handler.SortedSetHandler.java
@Override public Object merge(MergingContext context, Object object) { if (!(object instanceof SortedSet)) { return null; }/*from www . j a va 2 s .c o m*/ SortedSet<Object> source = (SortedSet<Object>) object; SortedSet<Object> result; if (source instanceof UninitializedPersistentSortedSet) { result = new PersistentSortedSet(context.getSessionImplementor(), source); context.addProcessedObject(object, result); } else { SortedSet<Object> set = new TreeSet<Object>(source.comparator()); context.addProcessedObject(object, set); for (Object element : source) { set.add(context.merge(element)); } result = set; } return result; }
From source file:org.sventon.rss.RssFeedGeneratorTest.java
@Test public void testGenerateFeedRSS20() throws Exception { final DefaultRssFeedGenerator generator = new DefaultRssFeedGenerator(); generator.setFeedType("rss_2.0"); generator.setLogMessageLength(20);/*from w ww.j a v a2s . co m*/ generator.setDateFormat("yyyyMMdd HH:mm:ss"); List<LogEntry> logEntries = new ArrayList<LogEntry>(); SortedSet<ChangedPath> changedPaths; final String logMessage = "< > / & ' ; \\"; changedPaths = new TreeSet<ChangedPath>(); changedPaths.add(new ChangedPath("/file1.java", null, 1, ChangeType.MODIFIED)); changedPaths.add(new ChangedPath("/file2.html", null, 1, ChangeType.DELETED)); changedPaths.add(new ChangedPath("/file3.abc", null, 1, ChangeType.ADDED)); changedPaths.add(new ChangedPath("/file4.def", null, 1, ChangeType.REPLACED)); logEntries.add(TestUtils.createLogEntry(1, "jesper", new Date(), logMessage, changedPaths)); changedPaths = new TreeSet<ChangedPath>(); changedPaths.add(new ChangedPath("/file1.java", null, 2, ChangeType.MODIFIED)); changedPaths.add(new ChangedPath("/file2.html", null, 2, ChangeType.DELETED)); changedPaths.add(new ChangedPath("/file3.abc", null, 2, ChangeType.ADDED)); changedPaths.add(new ChangedPath("/file4.def", "/file44.def", 1, ChangeType.REPLACED)); logEntries.add(TestUtils.createLogEntry(2, "jesper", new Date(), "Another\nlog message.", changedPaths)); final File tempFile = File.createTempFile("sventon-rss-test", null); final PrintWriter pw = new PrintWriter(tempFile); final MockHttpServletRequest req = new MockHttpServletRequest("get", "http://localhost:8888/svn/"); final MockHttpServletResponse res = new MockHttpServletResponse() { public PrintWriter getWriter() throws UnsupportedEncodingException { return pw; } }; generator.outputFeed(new RepositoryConfiguration("defaultsvn"), logEntries, req, res); pw.flush(); pw.close(); if (tempFile.exists()) { tempFile.delete(); } else { fail("No rss feed file was created in " + TestUtils.TEMP_DIR); } }