Example usage for java.util SortedSet size

List of usage examples for java.util SortedSet size

Introduction

In this page you can find the example usage for java.util SortedSet size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterTest.java

@Test
public void testCustomMessageWithParameters() throws Exception {
    DefaultConfiguration config = createCheckConfig(emptyCheck.getClass());
    config.addMessage("msgKey", "This is a custom message with {0}.");
    emptyCheck.configure(config);// w w w  .ja  va  2 s .c om

    LocalizedMessages collector = new LocalizedMessages();
    emptyCheck.setMessages(collector);

    emptyCheck.log(0, "msgKey", "TestParam");

    SortedSet<LocalizedMessage> messages = collector.getMessages();
    assertEquals(1, messages.size());

    assertEquals("This is a custom message with TestParam.", messages.first().getMessage());
}

From source file:com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterTest.java

@Test(expected = IllegalArgumentException.class)
public void testCustomMessageWithParametersNegative() throws Exception {
    DefaultConfiguration config = createCheckConfig(emptyCheck.getClass());
    config.addMessage("msgKey", "This is a custom message {0.");
    emptyCheck.configure(config);//from   w  ww.  j  ava2s .co  m

    LocalizedMessages collector = new LocalizedMessages();
    emptyCheck.setMessages(collector);

    emptyCheck.log(0, "msgKey", "TestParam");

    SortedSet<LocalizedMessage> messages = collector.getMessages();
    assertEquals(1, messages.size());

    //we expect an exception here because of the bogus custom message
    //format
    messages.first().getMessage();
}

From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java

@Test
public void testFindForEmptyPackage() throws IOException {
    // given//from  w w w.j  a  v a 2s .c o m
    String stacktraceFile = IOUtils.toString(StackTraceColorizer.class.getClassLoader()
            .getResourceAsStream("stacktrace/stacktTraceWtihEmptyPackage.txt"));

    // when
    SortedSet<SubText> findStackTraces = finder.findStackTraces(stacktraceFile);

    // then
    assertEquals(1, findStackTraces.size());
    SubText subtext = findStackTraces.iterator().next();
    assertEquals(0, subtext.start);
    assertEquals(213, subtext.end);
}

From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java

@Test
public void testFindStackTraces() throws IOException {
    // given/*from w w w  .  j a v a  2s  .  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:org.eclipse.skalli.services.extension.validators.WhitelistValidatorTest.java

private void assertNoIssues(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  .  j a v a  2s  .co  m*/
    Assert.assertEquals(0, issues.size());
}

From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java

@Test
public void testFindInOnlyStackTrace() throws IOException {
    // given// w  ww  .ja va  2  s. c o  m
    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//from ww w.  j a  v  a2 s .  com
    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.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);// w  w w  .ja  va2 s.c  om
    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)));
}

From source file:com.projity.contrib.calendar.ContribIntervals.java

public boolean add(Object o) {
    DateSpan toAdd = (DateSpan) o;/*from www .jav a2s.  c  o  m*/
    SortedSet set = headSet(o);
    if (set.size() > 0) {
        DateSpan interval = (DateSpan) set.last();
        if (interval.getEnd() >= toAdd.getStart())
            toAdd = mergeIntervals(toAdd, interval);
    }

    set = tailSet(o);
    if (set.size() > 0) {
        DateSpan interval = (DateSpan) set.first();
        if (toAdd.getEnd() >= interval.getStart())
            toAdd = mergeIntervals(toAdd, interval);
    }
    return super.add(toAdd);
}

From source file:org.powertac.common.OrderbookTests.java

@Test
public void testGetAsks() {
    Orderbook ob = new Orderbook(timeslot, 20.1, now);
    ob.addAsk(new OrderbookOrder(-3.3, 24.0)).addAsk(new OrderbookOrder(-2.1, 20.2))
            .addAsk(new OrderbookOrder(-5.6, 22.4)).addAsk(new OrderbookOrder(-6.2, null));
    SortedSet<OrderbookOrder> asks = ob.getAsks();
    assertEquals("correct number", 4, asks.size());
    assertEquals("no bids", 0, ob.getBids().size());
    assertNull("correct first", asks.first().getLimitPrice());
    assertEquals("correct last", 24.0, asks.last().getLimitPrice(), 1e-6);
}