org.jfree.data.time.SimpleTimePeriod Java Examples

The following examples show how to use org.jfree.data.time.SimpleTimePeriod. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the add() methods.
 */
public void testAdd() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    MySeriesChangeListener listener = new MySeriesChangeListener();
    tpv.addChangeListener(listener);
    tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), 
            new Date(3L)), 99.0));
    assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
    assertEquals(tpv, listener.getLastEvent().getSource());
    
    // a null item should throw an IllegalArgumentException
    boolean pass = false;
    try {
        tpv.add((TimePeriodValue) null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #2
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the add() methods.
 */
public void testAdd() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    MySeriesChangeListener listener = new MySeriesChangeListener();
    tpv.addChangeListener(listener);
    tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), 
            new Date(3L)), 99.0));
    assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
    assertEquals(tpv, listener.getLastEvent().getSource());
    
    // a null item should throw an IllegalArgumentException
    boolean pass = false;
    try {
        tpv.add((TimePeriodValue) null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #3
Source File: TimePeriodValuesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getDomainBounds() method.
 */
public void testGetDomainBoundsWithoutInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(false);
    assertNull(r);
    
    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(1500.0, r.getUpperBound(), EPSILON);
    
    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(2250.0, r.getUpperBound(), EPSILON);  
}
 
Example #4
Source File: TimePeriodValuesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getDomainBounds() method.
 */
public void testGetDomainBoundsWithoutInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(false);
    assertNull(r);
    
    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(1500.0, r.getUpperBound(), EPSILON);
    
    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(2250.0, r.getUpperBound(), EPSILON);  
}
 
Example #5
Source File: TimePeriodValuesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some more checks for the getDomainBounds() method.
 * 
 * @see #testGetDomainBoundsWithoutInterval()
 */
public void testGetDomainBoundsWithInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(true);
    assertNull(r);
    
    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(2000.0, r.getUpperBound(), EPSILON);
    
    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(3000.0, r.getUpperBound(), EPSILON);  
}
 
Example #6
Source File: ChartUtil.java    From ezScrum with GNU General Public License v2.0 6 votes vote down vote up
private XYDataset createBarDataset() {
	final TimePeriodValuesCollection result = new TimePeriodValuesCollection();
	Set<String> nameSet = this.m_dataSetMap.keySet();

	for (String name : nameSet) {
		final TimePeriodValues series = new TimePeriodValues(name);

		Map<Date, ? extends Number> map = m_dataSetMap.get(name);

		Iterator<Date> ir = map.keySet().iterator();

		while (ir.hasNext()) {
			Date key = ir.next();
			series.add(new SimpleTimePeriod(key, new Date(key.getTime()
					+ (m_interval * OneDay))), map.get(key));
		}

		result.addSeries(series);
	}
	return result;
}
 
Example #7
Source File: TimePeriodValuesCollectionTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some more checks for the getDomainBounds() method.
 * 
 * @see #testGetDomainBoundsWithoutInterval()
 */
public void testGetDomainBoundsWithInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(true);
    assertNull(r);
    
    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(2000.0, r.getUpperBound(), EPSILON);
    
    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(3000.0, r.getUpperBound(), EPSILON);
    
    // add a third time period
    s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(7000.0, r.getUpperBound(), EPSILON);

    // add a fourth time period
    s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(7000.0, r.getUpperBound(), EPSILON);    
}
 
Example #8
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getMinStartIndex() method.
 */
public void testGetMinStartIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMinStartIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMinStartIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(0, s.getMinStartIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(2, s.getMinStartIndex());
}
 
Example #9
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getMaxStartIndex() method.
 */
public void testGetMaxStartIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMaxStartIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMaxStartIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(1, s.getMaxStartIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(1, s.getMaxStartIndex());
}
 
Example #10
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getMinMiddleIndex() method.
 */
public void testGetMinMiddleIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMinMiddleIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMinMiddleIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(0, s.getMinMiddleIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(2, s.getMinMiddleIndex());
}
 
Example #11
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getMaxMiddleIndex() method.
 */
public void testGetMaxMiddleIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(1, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(1, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(150L, 200L), 4.0);
    assertEquals(1, s.getMaxMiddleIndex());
}
 
Example #12
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getMinEndIndex() method.
 */
public void getMinEndIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMinEndIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMinEndIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(0, s.getMinEndIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(2, s.getMinEndIndex());
}
 
Example #13
Source File: SimpleTimePeriodTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L),
            new Date(20L));
    SimpleTimePeriod s2 = new SimpleTimePeriod(new Date(10L),
            new Date(20L));
    assertTrue(s1.equals(s2));
    int h1 = s1.hashCode();
    int h2 = s2.hashCode();
    assertEquals(h1, h2);
}
 
Example #14
Source File: TaskTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));

    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));

    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));

    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));


}
 
Example #15
Source File: TaskTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));
    
    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));
    
    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));
    
    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));
    

}
 
Example #16
Source File: TaskTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));

    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));

    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));

    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));


}
 
Example #17
Source File: TaskSeriesCollectionTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}
 
Example #18
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getMaxEndIndex() method.
 */
public void getMaxEndIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMaxEndIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMaxEndIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(1, s.getMaxEndIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(1, s.getMaxEndIndex());
}
 
Example #19
Source File: SimpleTimePeriodTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that an instance is equal to itself.
 *
 * SourceForge Bug ID: 558850.
 */
public void testEqualsSelf() {
    SimpleTimePeriod p = new SimpleTimePeriod(
        new Date(1000L), new Date(1001L)
    );
    assertTrue(p.equals(p));
}
 
Example #20
Source File: SimpleTimePeriodTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    SimpleTimePeriod s1 = new SimpleTimePeriod(
        new Date(10L), new Date(20L)
    );
    SimpleTimePeriod s2 = new SimpleTimePeriod(
        new Date(10L), new Date(20L)
    );
    assertTrue(s1.equals(s2));
    int h1 = s1.hashCode();
    int h2 = s2.hashCode();
    assertEquals(h1, h2);
}
 
Example #21
Source File: SimpleTimePeriodTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 
 * This class is immutable, so it should not implement Cloneable.
 */
public void testClone() {
    SimpleTimePeriod s1 = new SimpleTimePeriod(
        new Date(10L), new Date(20L)
    );
    assertFalse(s1 instanceof Cloneable);
}
 
Example #22
Source File: TaskSeriesCollectionTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
@Test
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}
 
Example #23
Source File: TaskSeriesCollectionTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(), 
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(), 
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(), 
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(), 
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(), 
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(), 
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}
 
Example #24
Source File: TaskTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));

    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));

    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));

    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));


}
 
Example #25
Source File: TaskSeriesCollectionTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
@Test
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}
 
Example #26
Source File: TaskSeriesCollectionTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
@Test
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}
 
Example #27
Source File: TaskTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));

    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));

    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));

    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));


}
 
Example #28
Source File: TaskTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));

    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));

    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));

    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));


}
 
Example #29
Source File: TaskSeriesCollectionTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
@Test
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}
 
Example #30
Source File: TaskSeriesCollectionTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A test for bug report 697153.
 */
@Test
public void test697153() {

    TaskSeries s1 = new TaskSeries("S1");
    s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeries s2 = new TaskSeries("S2");
    s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(),
            new Date())));
    s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(),
            new Date())));

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(s1);
    tsc.add(s2);

    s1.removeAll();

    int taskCount = tsc.getColumnCount();

    assertEquals(3, taskCount);

}