DecisionPolicy 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 (!isPreparedToSave()) { prepareToSave(); } Path newPolicyPath = null; newPolicyPath = Paths.get(policyAdapter.getNewFileName()); successMap = createPolicy(newPolicyPath, getCorrectPolicyDataObject()); return successMap; } DecisionPolicy(); @Autowired  DecisionPolicy(CommonClassDao commonClassDao);  DecisionPolicy(PolicyRestAdapter policyAdapter); @Override Map<String, String> savePolicies(); @Override boolean prepareToSave(); PolicyType getGuardPolicy(Map<String, String> yamlParams, String ruleProvider); @Override Object getCorrectPolicyDataObject(); String getFunctionDefinitionId(String key); static final String FUNCTION_NOT; static final String GUARD_YAML; static final String GUARD_BL_YAML; static final String GUARD_MIN_MAX; static final String RAINY_DAY; static final String MS_MODEL; }
@Test public void testSavePolicies() { DecisionPolicy mockDecision = Mockito.mock(component.getClass()); Map<String, String> successMap = new HashMap<>(); successMap.put("success", "success"); try { when(mockDecision.savePolicies()).thenReturn(successMap); successMap = mockDecision.savePolicies(); } catch (Exception e) { e.printStackTrace(); } assertEquals(successMap.get("success"), "success"); }