/** Test getting a component for a test */ @Test public void testDataComponent() { ApplicationContext goodContext = new AnnotationConfigApplicationContext( new Class<?>[] {ContextConfigurationWithGoodMananger.class}); customizationAssemblyFactory.setApplicationContext(goodContext); // test good one Assert.assertEquals( simpleMaleStudentEntity, customizationAssemblyFactory.getDataComponentForTest( "panel", "1", configMap.get("panel").getData())); // test an entity mapping that throws an exception Assert.assertNull( customizationAssemblyFactory.getDataComponentForTest( "panelException", "1", configMap.get("panelException").getData())); // test non-existent one Config.Data fakeDataConfig = new Config.Data("fake", "fake", false, null); Assert.assertNotNull(fakeDataConfig); try { customizationAssemblyFactory.getDataComponentForTest("panel", "1", fakeDataConfig); Assert.fail("Must not be able to find fake entity reference and throw an exception"); } catch (DashboardException de) { Assert.assertEquals( "No entity mapping references found for " + fakeDataConfig.getEntityRef() + ". Fix!!!", de.getMessage()); } }