Merge "Added check in PUT policy"
authorHenrik Andersson <henrik.b.andersson@est.tech>
Thu, 9 Apr 2020 12:59:26 +0000 (12:59 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 9 Apr 2020 12:59:26 +0000 (12:59 +0000)
1  2 
policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java

@@@ -355,6 -355,7 +355,7 @@@ public class ApplicationTest 
          this.addRic("ric1");
          this.addRic("ricXXX");
          this.addPolicy("instance1", "type1", "service1", "ric1");
+         this.addPolicy("instance2", "type1", "service1", "ricXXX");
  
          // Try change ric1 -> ricXXX
          String urlWrongRic = putPolicyUrl("service1", "ricXXX", "type1", "instance1");
          testErrorCode(restClient().put("/service", "crap"), HttpStatus.BAD_REQUEST);
          testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST);
          testErrorCode(restClient().put("/service", createServiceJson("name", -123)), HttpStatus.BAD_REQUEST);
 +        testErrorCode(restClient().put("/service", createServiceJson("name", 0, "missing.portandprotocol.com")),
 +            HttpStatus.BAD_REQUEST);
  
          // GET non existing servive
          testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND);
      }
  
      private String createServiceJson(String name, long keepAliveIntervalSeconds) {
 -        ServiceRegistrationInfo service = new ServiceRegistrationInfo(name, keepAliveIntervalSeconds, "callbackUrl");
 +        return createServiceJson(name, keepAliveIntervalSeconds, "https://examples.javacodegeeks.com/core-java/");
 +    }
 +
 +    private String createServiceJson(String name, long keepAliveIntervalSeconds, String url) {
 +        ServiceRegistrationInfo service = new ServiceRegistrationInfo(name, keepAliveIntervalSeconds, url);
  
          String json = gson.toJson(service);
          return json;