/** * Simple test verifying the expected state can be set and retrieved * * @throws Exception */ @Test public void testExpectedState() throws Exception { PersonCreationIdPolicyImpl underTest = new PersonCreationIdPolicyImpl(); underTest.setExpectedState(EXISTS); assertEquals(EXISTS, underTest.getExpectedState()); underTest.setExpectedState(DOES_NOT_EXIST); assertEquals(DOES_NOT_EXIST, underTest.getExpectedState()); }
/** * Verifies that all permissible values of IdPolicy can be obtained by looking up the business ID * state. * * @throws Exception */ @Test public void testGetIdPolicyActionForState() throws Exception { PersonCreationIdPolicyImpl underTest = new PersonCreationIdPolicyImpl(); Map<BusinessIdState, IdPolicyAction> policyActionMap = new HashMap<BusinessIdState, IdPolicyAction>(); policyActionMap.put(EXISTS, ACCEPT); policyActionMap.put(DOES_NOT_EXIST, REJECT); policyActionMap.put(ANY, SUBSTITUTE); policyActionMap.put(null, REPLACE); underTest.setPolicyActionMap(policyActionMap); assertEquals(REPLACE, underTest.getIdPolicyActionForState(null)); assertEquals(SUBSTITUTE, underTest.getIdPolicyActionForState(ANY)); assertEquals(REJECT, underTest.getIdPolicyActionForState(DOES_NOT_EXIST)); assertEquals(ACCEPT, underTest.getIdPolicyActionForState(EXISTS)); // Clear the map policyActionMap.clear(); underTest.setPolicyActionMap(policyActionMap); // note that null can be returned assertNull(underTest.getIdPolicyActionForState(EXISTS)); }
/** * Test verifying the policy action map can be retrieved, and that it is defensively copied upon * retrieval * * @throws Exception */ @Test public void testGetPolicyActionMap() throws Exception { PersonCreationIdPolicyImpl underTest = new PersonCreationIdPolicyImpl(); Map<BusinessIdState, IdPolicyAction> policyActionMap = new HashMap<BusinessIdState, IdPolicyAction>(); policyActionMap.put(EXISTS, ACCEPT); policyActionMap.put(DOES_NOT_EXIST, REJECT); policyActionMap.put(ANY, SUBSTITUTE); policyActionMap.put(null, REPLACE); // Assert the map can be set and retrieved underTest.setPolicyActionMap(policyActionMap); assertEquals(policyActionMap, underTest.getPolicyActionMap()); // Assert that the map is defensively copied when retrieved underTest.getPolicyActionMap().clear(); assertTrue(policyActionMap.equals(underTest.getPolicyActionMap())); }