ActionPolicy extends Policy { @Override public Map<String, String> savePolicies() throws PAPException { Map<String, String> successMap = new HashMap<>(); if (isPolicyExists()) { successMap.put("EXISTS", "This Policy already exist on the PAP"); return successMap; } if (!ActionPolicy.getAttribute()) { successMap.put("invalidAttribute", "Action Attrbute was not in the database."); return successMap; } if (!isPreparedToSave()) { prepareToSave(); } Path newPolicyPath = null; newPolicyPath = Paths.get(policyAdapter.getNewFileName()); successMap = createPolicy(newPolicyPath, getCorrectPolicyDataObject()); return successMap; } ActionPolicy();  ActionPolicy(PolicyRestAdapter policyAdapter, CommonClassDao commonClassDao); @Override Map<String, String> savePolicies(); @Override boolean prepareToSave(); @Override Object getCorrectPolicyDataObject(); String getFunctionDefinitionId(String key); static final String JSON_CONFIG; static final String PDP_ACTION; static final String PEP_ACTION; static final String TYPE_ACTION; static final String GET_METHOD; static final String PUT_METHOD; static final String POST_METHOD; static final String PERFORMER_ATTRIBUTEID; static final String TYPE_ATTRIBUTEID; static final String METHOD_ATTRIBUTEID; static final String HEADERS_ATTRIBUTEID; static final String URL_ATTRIBUTEID; static final String BODY_ATTRIBUTEID; }
@Test public void testSavePolicies() { ActionPolicy mockAction = Mockito.mock(component.getClass()); Map<String, String> successMap = new HashMap<>(); successMap.put("success", "success"); try { when(mockAction.savePolicies()).thenReturn(successMap); successMap = mockAction.savePolicies(); } catch (Exception e) { logger.error("Exception Occured" + e); } assertEquals(successMap.get("success"), "success"); }