List of usage examples for java.util SortedSet iterator
Iterator<E> iterator();
From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java
@Test public void testFindStackTraces() throws IOException { // given/*from w w w .jav a 2 s . c o m*/ String stacktraceFile = IOUtils.toString( StackTraceColorizer.class.getClassLoader().getResourceAsStream("stacktrace/stacktrace.txt")); // when SortedSet<SubText> findStackTraces = finder.findStackTraces(stacktraceFile); // then assertEquals(1, findStackTraces.size()); SubText subtext = findStackTraces.iterator().next(); assertEquals(10, subtext.start); assertEquals(241, subtext.end); }
From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java
@Test public void testFindInOnlyStackTrace() throws IOException { // given//from w w w .ja v a 2 s. com String stacktraceFile = IOUtils.toString( StackTraceColorizer.class.getClassLoader().getResourceAsStream("stacktrace/stacktTraceOnly.txt")); // when SortedSet<SubText> findStackTraces = finder.findStackTraces(stacktraceFile); // then assertEquals(1, findStackTraces.size()); SubText subtext = findStackTraces.iterator().next(); // TODO check range assertEquals(0, subtext.start); assertEquals(234, subtext.end); }
From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java
@Test public void testFind2StackTraces() throws IOException { // given//w ww . j ava 2s. c om String stacktraceFile = IOUtils.toString( StackTraceColorizer.class.getClassLoader().getResourceAsStream("stacktrace/stacktrace2.txt")); // when SortedSet<SubText> findStackTraces = finder.findStackTraces(stacktraceFile); // then assertEquals(2, findStackTraces.size()); Iterator<SubText> iterator = findStackTraces.iterator(); SubText subtext = iterator.next(); assertEquals(44, subtext.start); assertEquals(3142, subtext.end); subtext = iterator.next(); assertEquals(3183, subtext.start); assertEquals(3439, subtext.end); }
From source file:org.opencastproject.archive.opencast.solr.SolrIndexManager.java
/** * Gets the maximum confidence for a given keyword in the text annotation. * /* w w w .j a v a 2 s . c om*/ * @param keyword * @param sortedAnnotations * @return The maximum confidence value. */ static double getMaxConfidence(String keyword, SortedSet<TextAnnotation> sortedAnnotations) { double max = 0.0; String needle = null; TextAnnotation textAnnotation = null; Iterator<TextAnnotation> textAnnotations = sortedAnnotations.iterator(); while (textAnnotations.hasNext()) { textAnnotation = textAnnotations.next(); Iterator<KeywordAnnotation> keywordAnnotations = textAnnotation.keywordAnnotations(); while (keywordAnnotations.hasNext()) { KeywordAnnotation ann = keywordAnnotations.next(); needle = ann.getKeyword().toLowerCase(); if (keyword.equals(needle)) { if (max < textAnnotation.getConfidence()) { max = textAnnotation.getConfidence(); } } } } return max; }
From source file:org.opencastproject.archive.opencast.solr.SolrIndexManager.java
/** * Gets the maximum relevance for a given keyword in the text annotation. * /*from w ww .j av a 2 s . co m*/ * @param keyword * @param sortedAnnotations * @return The maximum relevance value. */ static double getMaxRelevance(String keyword, SortedSet<TextAnnotation> sortedAnnotations) { double max = 0.0; String needle = null; TextAnnotation textAnnotation = null; Iterator<TextAnnotation> textAnnotations = sortedAnnotations.iterator(); while (textAnnotations.hasNext()) { textAnnotation = textAnnotations.next(); Iterator<KeywordAnnotation> keywordAnnotations = textAnnotation.keywordAnnotations(); while (keywordAnnotations.hasNext()) { KeywordAnnotation ann = keywordAnnotations.next(); needle = ann.getKeyword().toLowerCase(); if (keyword.equals(needle)) { if (max < textAnnotation.getRelevance()) { max = textAnnotation.getRelevance(); } } } } return max; }
From source file:am.ik.categolj2.domain.model.CategoryTest.java
@Test public void testInTreeSet() { Category c1 = new Category(1, 1, "Programmming"); Category c2 = new Category(1, 2, "Java"); Category c3 = new Category(1, 3, "org"); Category c4 = new Category(2, 4, "springframework"); Category c5 = new Category(1, 5, "core"); SortedSet<Category> categories = new TreeSet<Category>(); // added randomly categories.add(c3);//from w ww . j a v a 2 s . c o m categories.add(c1); categories.add(c5); categories.add(c2); categories.add(c4); Iterator<Category> iterator = categories.iterator(); assertThat(iterator.next(), is(c1)); assertThat(iterator.next(), is(c2)); assertThat(iterator.next(), is(c3)); assertThat(iterator.next(), is(c4)); assertThat(iterator.next(), is(c5)); }
From source file:io.pravega.client.batch.impl.BatchClientImpl.java
private Iterator<SegmentInfo> listSegments(Stream stream, Date from) { // modify iteration above but starting with a timestamp and ending with a break Map<Segment, Long> segments = getAndHandleExceptions(controller.getSegmentsAtTime( new StreamImpl(stream.getScope(), stream.getStreamName()), from.getTime()), RuntimeException::new); SortedSet<Segment> result = new TreeSet<>(); result.addAll(segments.keySet());/* w w w. ja va 2s . co m*/ result.addAll(getAndHandleExceptions(controller.getSuccessors(new StreamCut(stream, segments)), RuntimeException::new)); return Iterators.transform(result.iterator(), s -> segmentToInfo(s)); }
From source file:ru.retbansk.utils.scheduled.impl.ReadEmailAndConvertToXmlSpringImplTest.java
@Test public void readEmailTest() throws Exception { HashSet<DayReport> daySet = reader.readEmail(); Assert.assertNotNull(daySet);// w w w.jav a 2s. c o m Assert.assertEquals(2, daySet.size()); DayReport fromTester = null; DayReport fromAnotherTester = null; SortedSet<DayReport> sortedDaySet = new TreeSet<DayReport>(); sortedDaySet.addAll(daySet); Assert.assertEquals(2, sortedDaySet.size()); Iterator<DayReport> iterator = sortedDaySet.iterator(); while (iterator.hasNext()) { fromAnotherTester = iterator.next(); fromTester = iterator.next(); } Assert.assertNotNull(fromAnotherTester); Assert.assertNotNull(fromTester); Assert.assertEquals(USER2, fromTester.getPersonId()); Assert.assertEquals(USER, fromAnotherTester.getPersonId()); Assert.assertEquals(3, fromTester.getReportList().size()); Assert.assertEquals(1, fromAnotherTester.getReportList().size()); Assert.assertEquals(TEST_STRING, fromTester.getReportList().get(0).getWorkDescription()); Assert.assertEquals(8, fromAnotherTester.getReportList().get(0).getElapsedTime()); Assert.assertEquals(TEST_STRING2, fromTester.getReportList().get(2).getWorkDescription()); }
From source file:org.geoserver.security.iride.IrideRoleServiceTest.java
public void testGetRolesForBaseUser() throws IOException { //config.setServerURL("http://localhost:8085/iride2simApplIridepepWsfad/services/iride2simIridepep"); IrideRoleService roleService = wrapRoleService(createRoleService(), "base"); SortedSet<GeoServerRole> roles = roleService.getRolesForUser(BASE_SAMPLE_USER); assertNotNull(roles);// www. j a v a 2 s . c om assertEquals(1, roles.size()); assertEquals("BASEUSER_SIIG", roles.iterator().next().toString()); }
From source file:org.geoserver.security.iride.IrideRoleServiceTest.java
public void testGetRolesForMajorUser() throws IOException { IrideRoleService roleService = wrapRoleService(createRoleService(), "major"); SortedSet<GeoServerRole> roles = roleService.getRolesForUser(MAJOR_SAMPLE_USER); assertNotNull(roles);/*from w ww .j av a 2s . c o m*/ assertEquals(1, roles.size()); assertEquals("MAJORUSER_SIIG", roles.iterator().next().toString()); }