- @Test
- public void testConstructor1() {
- thrown.expect(NullPointerException.class);
- MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy();
- policy.getCorrectPolicyDataObject();
- fail("Expected an exception");
- }
-
- @Test
- public void testConstructor2() {
- PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
- MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy(policyAdapter);
- assertNull(policy.getCorrectPolicyDataObject());
- }
-
- @Test
- public void testPrepareToSave() throws PAPException {
- thrown.expect(NullPointerException.class);
- PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
- MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy(policyAdapter);
- policyAdapter.setHighestVersion(1);
- policyAdapter.setPolicyType("Config");
- policyAdapter.setNewFileName("foo.xml");
- policyAdapter.setJsonBody("{ \"version\": \"1.0\"}");
- policyAdapter.setServiceType("foo");
- policy.prepareToSave();
- fail("Expected an exception");
- }
-}
\ No newline at end of file
+ @Test
+ public void testConstructor1() {
+ thrown.expect(NullPointerException.class);
+ MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy();
+ policy.getCorrectPolicyDataObject();
+ fail("Expected an exception");
+ }
+
+ @Test
+ public void testConstructor2() {
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy(policyAdapter);
+ assertNull(policy.getCorrectPolicyDataObject());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSave() throws PAPException {
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ PolicyType policyType = new PolicyType();
+ policyAdapter.setPolicyID("id");
+ policyAdapter.setHighestVersion(1);
+ policyAdapter.setPolicyType("Config");
+ policyAdapter.setNewFileName("newfile");
+ policyAdapter.setData(policyType);
+ policyAdapter.setJsonBody("{\"key\":\"value\"}");
+ policyAdapter.setServiceType("svcType");
+ MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy(policyAdapter);
+
+ policy.savePolicies();
+ }
+
+ @Test
+ public void testAdvice() {
+ 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");
+
+ MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy(policyAdapter);
+ assertThatThrownBy(() -> policy.savePolicies()).isInstanceOf(NullPointerException.class);
+
+ AdviceExpressionsType expType = policy.getAdviceExpressions(1, "filename");
+ assertEquals(1, expType.getAdviceExpression().size());
+ }
+}