List of usage examples for java.util SortedSet first
E first();
From source file:org.apache.hadoop.hbase.regionserver.MutableCellSetSegment.java
@Override public Cell getFirstAfter(Cell cell) { SortedSet<Cell> snTailSet = tailSet(cell); if (!snTailSet.isEmpty()) { return snTailSet.first(); }//www . j a va 2 s . co m return null; }
From source file:org.openmrs.module.amrsreports.reporting.data.evaluator.ICAPObsNearestARVStartDateDataEvaluator.java
@Override protected Object doExecute(Integer pId, SortedSet<ObsRepresentation> o, EvaluationContext context) { ObsRepresentation or = o.first(); if (!or.getObsDatetime().after(context.getEvaluationDate())) return or; return null;/*from w ww. ja v a2s .c o m*/ }
From source file:ca.travelagency.invoice.InvoicePersistenceTest.java
@Test public void testAddNote() throws Exception { // setup//from w w w . j a v a 2s. c o m Invoice invoice = InvoiceHelper.makeInvoiceWithoutId(customer, systemUser); InvoiceNote expected = InvoiceHelper.makeNoteWithoutId(); // execute invoice.addInvoiceNote(expected); persist(invoice); // validate validateRelationship(expected); Invoice result = find(Invoice.class, invoice.getId()); // validate SortedSet<InvoiceNote> invoiceNotes = result.getInvoiceNotes(); InvoiceNote actual = invoiceNotes.first(); Assert.assertEquals(expected, actual); Assert.assertNotSame(expected, actual); }
From source file:org.cloudata.core.parallel.hadoop.KeyRangePartitioner.java
@Override public int getPartition(WritableComparable key, Writable value, int numPartitions) { if (confException != null) { LOG.error(confException.getMessage(), confException); return -1; }//w w w .j a v a2 s .c om if (tabletInfoSet.isEmpty()) { LOG.error("tablet partition size is zero"); return -1; } int partitionNumber = 0; Row.Key rowKey = new Row.Key(key.toString()); SortedSet<RowKeyItem> tailSet = tabletInfoSet.tailSet(new RowKeyItem(rowKey, 0)); if (!tailSet.isEmpty()) { partitionNumber = tailSet.first().index; } else { partitionNumber = tabletInfoSet.last().index; } if (partitionNumber >= numPartitions) { LOG.info("Partition Number is : " + partitionNumber + ", numPartitions : " + numPartitions + ", Row.Key : " + key.toString()); partitionNumber = numPartitions - 1; } count++; return partitionNumber; }
From source file:com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterTest.java
@Test public void testCustomMessage() throws Exception { DefaultConfiguration config = createCheckConfig(emptyCheck.getClass()); config.addMessage("msgKey", "This is a custom message."); emptyCheck.configure(config);/*from ww w .ja v a 2 s. c o m*/ LocalizedMessages collector = new LocalizedMessages(); emptyCheck.setMessages(collector); emptyCheck.log(0, "msgKey"); SortedSet<LocalizedMessage> messages = collector.getMessages(); assertEquals(1, messages.size()); assertEquals("This is a custom message.", messages.first().getMessage()); }
From source file:pl.otros.logview.gui.message.SoapFinderTest.java
@Test public void testFindSoap() throws Exception { String stringWithSoaps = IOUtils .toString(this.getClass().getClassLoader().getResourceAsStream("soap/stringWithSoap.txt")); SoapFinder finder = new SoapFinder(); SortedSet<SubText> findSoaps = finder.findSoaps(stringWithSoaps); // 60,300//www .j a v a2 s . co m AssertJUnit.assertEquals(2, findSoaps.size()); SubText first = findSoaps.first(); stringWithSoaps.substring(first.getStart(), first.getEnd()); AssertJUnit.assertEquals(38, first.getStart()); AssertJUnit.assertEquals(299, first.getEnd()); SubText last = findSoaps.last(); stringWithSoaps.substring(last.getStart(), last.getEnd()); AssertJUnit.assertEquals(369, last.getStart()); AssertJUnit.assertEquals(645, last.getEnd()); }
From source file:org.jclouds.aws.s3.xml.S3ParserTest.java
@Test public void testCanParseListAllMyBuckets() throws HttpException { SortedSet<BucketMetadata> s3Buckets = runParseListAllMyBuckets(); BucketMetadata container1 = s3Buckets.first(); assert container1.getName().equals("adrianjbosstest"); DateTime expectedDate1 = new DateTime("2009-03-12T02:00:07.000Z"); DateTime date1 = container1.getCreationDate(); assert date1.equals(expectedDate1); BucketMetadata container2 = (BucketMetadata) s3Buckets.toArray()[1]; assert container2.getName().equals("adrianjbosstest2"); DateTime expectedDate2 = new DateTime("2009-03-12T02:00:09.000Z"); DateTime date2 = container2.getCreationDate(); assert date2.equals(expectedDate2); assert s3Buckets.size() == 2; CanonicalUser owner = new CanonicalUser("e1a5f66a480ca99a4fdfe8e318c3020446c9989d7004e7778029fbcc5d990fa0"); assert container1.getOwner().equals(owner); assert container2.getOwner().equals(owner); }
From source file:ca.travelagency.invoice.InvoicePersistenceTest.java
@Test public void testAddPayment() throws Exception { // setup//from ww w. j a v a 2 s. c om Invoice invoice = InvoiceHelper.makeInvoiceWithoutId(customer, systemUser); InvoicePayment expected = InvoiceHelper.makePaymentWithoutId(); // execute invoice.addInvoicePayment(expected); persist(invoice); // validate validateRelationship(expected); Invoice result = find(Invoice.class, invoice.getId()); // validate SortedSet<InvoicePayment> invoicePayments = result.getInvoicePayments(); InvoicePayment actual = invoicePayments.first(); Assert.assertEquals(expected, actual); Assert.assertNotSame(expected, actual); }
From source file:ca.travelagency.invoice.InvoicePersistenceTest.java
@Test public void testAddTraveler() throws Exception { // setup//w w w .j a v a2 s. c o m Invoice invoice = InvoiceHelper.makeInvoiceWithoutId(customer, systemUser); InvoiceTraveler expected = InvoiceHelper.makeTravelerWithoutId(); // execute invoice.addInvoiceTraveler(expected); persist(invoice); // validate validateRelationship(expected); Invoice result = find(Invoice.class, invoice.getId()); // validate SortedSet<InvoiceTraveler> invoiceTravelers = result.getInvoiceTravelers(); InvoiceTraveler actual = invoiceTravelers.first(); Assert.assertEquals(expected, actual); Assert.assertNotSame(expected, actual); }
From source file:org.eclipse.skalli.services.extension.validators.WhitelistValidatorTest.java
private void assertHasIssue(String s) { WhitelistValidator validator = new WhitelistValidator(Severity.FATAL, TestExtension.class, TestExtension.PROPERTY_STR, Whitelist.basic()); SortedSet<Issue> issues = validator.validate(TestUUIDs.TEST_UUIDS[0], s, Severity.FATAL); Assert.assertNotNull(issues);// ww w . ja v a 2 s .com Assert.assertEquals(1, issues.size()); Assert.assertEquals(TestUUIDs.TEST_UUIDS[0], issues.first().getEntityId()); Assert.assertEquals(TestExtension.class, issues.first().getExtension()); Assert.assertEquals(TestExtension.PROPERTY_STR, issues.first().getPropertyId()); Assert.assertEquals(Severity.FATAL, issues.first().getSeverity()); Assert.assertTrue(issues.first().getMessage().contains(StringEscapeUtils.escapeHtml(s))); }