63 lines
1.5 KiB
Java
63 lines
1.5 KiB
Java
package jmri.jmrit.whereused;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.swing.JTextArea;
|
|
|
|
import jmri.NamedBean;
|
|
import jmri.NamedBeanUsageReport;
|
|
import jmri.implementation.AbstractSensor;
|
|
import jmri.util.JUnitUtil;
|
|
|
|
import org.junit.jupiter.api.*;
|
|
|
|
/**
|
|
* Tests for the SensorWhereUsed Class
|
|
*
|
|
* @author Dave Sand Copyright (C) 2020
|
|
*/
|
|
public class SensorWhereUsedTest {
|
|
|
|
// No Ctor test, class supplies static method.
|
|
|
|
private NamedBean t;
|
|
|
|
@Test
|
|
public void testSensorWhereUsedList() {
|
|
|
|
List<NamedBeanUsageReport> list =
|
|
assertDoesNotThrow( () ->
|
|
t.getUsageReport(t) );
|
|
assertEquals( 0, list.size());
|
|
}
|
|
|
|
@Test
|
|
public void testSensorWhereUsed() {
|
|
|
|
JTextArea ta = assertDoesNotThrow( () ->
|
|
SensorWhereUsed.getWhereUsed(t) );
|
|
assertTrue( ta.getText().contains(t.getDisplayName()));
|
|
assertTrue( ta.getText().contains("Listener count: 0"));
|
|
}
|
|
|
|
@BeforeEach
|
|
public void setUp() {
|
|
JUnitUtil.setUp();
|
|
t = new AbstractSensor("1234"){
|
|
@Override
|
|
public void requestUpdateFromLayout() {}
|
|
};
|
|
}
|
|
|
|
@AfterEach
|
|
public void tearDown() {
|
|
t = null;
|
|
JUnitUtil.deregisterBlockManagerShutdownTask();
|
|
JUnitUtil.tearDown();
|
|
}
|
|
}
|