/** * Test the {@link FundingSourceController#get(UUID)} action. * * @throws Exception Thrown if the controller throws any exceptions. */ @Test public void testControllerGet() throws Exception { assertNotNull( "Controller under test was not initialized by the container correctly.", controller); final FundingSourceTO obj = controller.get(FUNDINGSOURCE_ID); assertNotNull("Returned FundingSourceTO from the controller should not have been null.", obj); assertEquals("Returned FundingSource.Name did not match.", FUNDINGSOURCE_NAME, obj.getName()); }
/** * Test the {@link FundingSourceController#create(FundingSourceTO)} and {@link * FundingSourceController#delete(UUID)} actions. * * @throws Exception Thrown if the controller throws any exceptions. */ @Test public void testControllerCreateAndDelete() throws Exception { assertNotNull( "Controller under test was not initialized by the container correctly.", controller); final String testString1 = "testString1"; // NOPMD by jon.adams final String testString2 = "testString2"; // NOPMD by jon.adams // Check validation of 'no ID for create()' FundingSourceTO obj = new FundingSourceTO(UUID.randomUUID(), testString1, testString2); try { obj = controller.create(obj); fail( "Calling create with an object with an ID should have thrown a validation excpetion."); // NOPMD } catch (final ValidationException exc) { // NOPMD by jon.adams on // 5/14/12 /* expected */ } // Now create a valid FundingSource obj = new FundingSourceTO(null, testString1, testString2); obj = controller.create(obj); assertNotNull("Returned FundingSourceTO from the controller should not have been null.", obj); assertNotNull( "Returned FundingSourceTO.ID from the controller should not have been null.", obj.getId()); assertEquals( "Returned FundingSourceTO.Name from the controller did not match.", testString1, obj.getName()); assertEquals( "Returned FundingSourceTO.CreatedBy was not correctly auto-filled for the current user (the administrator in this test suite).", Person.SYSTEM_ADMINISTRATOR_ID, obj.getCreatedBy().getId()); assertTrue("Delete action did not return success.", controller.delete(obj.getId()).isSuccess()); }