@Test public void testSave() throws PAPException { PolicyType policyType = new PolicyType(); PolicyRestAdapter policyAdapter = new PolicyRestAdapter(); policyAdapter.setPolicyID("id"); policyAdapter.setHighestVersion(1); policyAdapter.setPolicyType("Config"); policyAdapter.setNewFileName("newfile"); policyAdapter.setData(policyType); policyAdapter.setJsonBody("{\"key\":\"value\"}"); policyAdapter.setServiceType("svcType"); OptimizationConfigPolicy policy = new OptimizationConfigPolicy(policyAdapter); assertThatThrownBy(() -> policy.savePolicies()).isInstanceOf(Exception.class); }
@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; }
OptimizationConfigPolicy 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; } }
OptimizationConfigPolicy 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; } OptimizationConfigPolicy();  OptimizationConfigPolicy(PolicyRestAdapter policyAdapter); }
OptimizationConfigPolicy 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; } OptimizationConfigPolicy();  OptimizationConfigPolicy(PolicyRestAdapter policyAdapter); @Override Map<String, String> savePolicies(); @Override boolean prepareToSave(); @Override Object getCorrectPolicyDataObject(); }
OptimizationConfigPolicy 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; } OptimizationConfigPolicy();  OptimizationConfigPolicy(PolicyRestAdapter policyAdapter); @Override Map<String, String> savePolicies(); @Override boolean prepareToSave(); @Override Object getCorrectPolicyDataObject();  }