use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class UicStats_Test method testGetUI.
/**
* Test getUI.
*/
@Test
public void testGetUI() {
WComponent resultComponent = stats.getUI();
Assert.assertEquals("should return component from constructor", app, resultComponent);
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class UicStats_Test method testGetWCTreeStats.
/**
* Test getWCTreeStats.
*/
@Test
public void testGetWCTreeStats() {
stats.analyseWC(app);
Map<WComponent, Stat> resultStats = stats.getWCTreeStats(app);
// label
for (Map.Entry<WComponent, Stat> entry : resultStats.entrySet()) {
WComponent comp = entry.getKey();
Stat stat = entry.getValue();
if (comp instanceof WLabel) {
Assert.assertEquals("this should be the label created", label, comp);
Assert.assertEquals("stat should have correct label name", label.getId(), stat.getName());
} else if (comp instanceof WButton) {
Assert.assertEquals("this should be the button in the app", button, comp);
Assert.assertEquals("stat should have correct button name", button.getId(), stat.getName());
} else if (comp instanceof WApplication) {
Assert.assertEquals("this should be the app", app, comp);
Assert.assertEquals("stat should have correct app name", app.getId(), stat.getName());
}
}
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class UIRegistryAmicableImpl_Test method testGetUINotRegisteredWComponent.
/**
* Test getUI - nothing registered - but WComponent creatable from key.
*/
@Test
public void testGetUINotRegisteredWComponent() {
final String key = "com.github.bordertech.wcomponents.WButton";
UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
WComponent result = reg.getUI(key);
Assert.assertTrue("should return an instantiated WComponent", result instanceof WComponent);
Assert.assertTrue("the WComponent should be in the registry", reg.isRegistered(key));
Assert.assertTrue("the WComponent should be locked", result.isLocked());
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class UIRegistryAmicableImpl_Test method testGetUINotRegisteredNotWComponent.
/**
* Test getUI - nothing registered - class creatable from key - but not a WComponent.
*/
@Test
public void testGetUINotRegisteredNotWComponent() {
final String key = "java.lang.String";
final String expectedClassName = FatalErrorPage.class.getName();
UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
WComponent result = reg.getUI(key);
Assert.assertNotNull("should return a fatal error page - when no WComponentclass", result);
Assert.assertEquals("should be of the expected type", expectedClassName, result.getClass().getName());
Assert.assertFalse("should not be cached", reg.isRegistered(key));
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class UIRegistryAmicableImpl_Test method testGetUINotRegisteredNoClass.
/**
* Test getUI - nothing registered - no class creatable from key - returns. FatalErrorPage
*/
@Test
public void testGetUINotRegisteredNoClass() {
final String key = "NO_CLASS_BY_THIS_NAME";
final String expectedClassName = FatalErrorPage.class.getName();
UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
WComponent result = reg.getUI(key);
Assert.assertNotNull("should return a fatal error page - when no class found", result);
Assert.assertEquals("should be of the expected type", expectedClassName, result.getClass().getName());
Assert.assertFalse("should not be cached", reg.isRegistered(key));
}
Aggregations