Update baseUrl of pms_v2.0
[portal/nonrtric-controlpanel.git] / webapp-backend / src / test / java / org / oransc / portal / nonrtric / controlpanel / RestApiTest.java
index c4acad2..5309d98 100644 (file)
@@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 
 import java.io.BufferedReader;
@@ -72,7 +72,8 @@ class RestApiTest {
         String url = "/v2/api-docs";
         ResponseEntity<String> resp = restClient().getForEntity(url).block();
         assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);
-        JsonElement jsonElement = JsonParser.parseString(resp.getBody());
+        JsonObject jsonElement = JsonParser.parseString(resp.getBody()).getAsJsonObject();
+        jsonElement.remove("host");
         String indented = gson.toJson(jsonElement);
         try (PrintStream out = new PrintStream(new FileOutputStream("../docs/api.json"))) {
             out.println(indented);
@@ -93,8 +94,16 @@ class RestApiTest {
             .targetUri("http://example.com/") //
             .owner("owner") //
             .build();
-        assertThat(jobs).hasSize(1) //
-            .contains(gson.toJsonTree(wantedJobInfo));
+        JobInfo wantedJobInfo2 = JobInfo.builder() //
+            .id("job2") //
+            .typeId("type2") //
+            .jobData(getStringFromFile("job-2.json")) //
+            .targetUri("http://example.com/") //
+            .owner("owner") //
+            .build();
+        assertThat(jobs).hasSize(6) //
+            .contains(gson.toJsonTree(wantedJobInfo), //
+            gson.toJsonTree(wantedJobInfo2));
     }
 
     @Test
@@ -110,8 +119,20 @@ class RestApiTest {
             .types(new String[] {"type1", "type2"}) //
             .status("ENABLED") //
             .build();
-        assertThat(producers).hasSize(1) //
-            .contains(gson.toJsonTree(wantedProducerInfo));
+        ProducerInfo wantedProducerInfo2 = ProducerInfo.builder() //
+            .id("prod-2") //
+            .types(new String[] {"type1"}) //
+            .status("DISABLED") //
+            .build();
+        ProducerInfo wantedProducerInfo3 = ProducerInfo.builder() //
+            .id("3-prod") //
+            .types(new String[] {"type1", "type2"}) //
+            .status("ENABLED") //
+            .build();
+        assertThat(producers).hasSize(3) //
+            .contains(gson.toJsonTree(wantedProducerInfo), //
+            gson.toJsonTree(wantedProducerInfo2), //
+            gson.toJsonTree(wantedProducerInfo3));
     }
 
     private AsyncRestClient restClient() {