diff --git a/src/test/java/itest/GraphQLTest.java b/src/test/java/itest/GraphQLTest.java index 90ecf5daa..6f7f6d14d 100644 --- a/src/test/java/itest/GraphQLTest.java +++ b/src/test/java/itest/GraphQLTest.java @@ -48,6 +48,8 @@ import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.HttpResponse; +import itest.GraphQLTest.ActiveRecording.DoPutMetadata; +import itest.GraphQLTest.DeleteMutationResponse; import itest.bases.StandardSelfTest; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -311,7 +313,7 @@ void testArchiveMutation() throws Exception { deleteRecording(); } - @Disabled + /* @Disabled @Test @Order(5) void testActiveRecordingMetadataMutation() throws Exception { @@ -348,29 +350,118 @@ void testActiveRecordingMetadataMutation() throws Exception { MatcherAssert.assertThat( actual.getData().getArchiveRecording(), Matchers.not(Matchers.empty())); - MatcherAssert.assertThat(actual.getData().getArchiveRecording(), Matchers.hasSize(1)); + MatcherAssert.assertThat(actual.getData().getArchiveRecording(), Matchers.hasSize(1)); */ + + // MatcherAssert.assertThat(actual.getData().getTargetNodes(), Matchers.hasSize(1)); - // MatcherAssert.assertThat(actual.getData().getTargetNodes(), Matchers.hasSize(1)); + // TargetNode node = actual.data.targetNodes.get(0); - // TargetNode node = actual.data.targetNodes.get(0); + // MatcherAssert.assertThat(node.recordings.active.data, Matchers.hasSize(1)); - // MatcherAssert.assertThat(node.recordings.active.data, Matchers.hasSize(1)); + /* ActiveRecording activeRecording = actual.getData().recordings.active.data.get(0); - /* ActiveRecording activeRecording = actual.getData().recordings.active.data.get(0); + MatcherAssert.assertThat( + activeRecording.metadata, + Matchers.equalTo( + RecordingMetadata.of( + Map.of( + "template.name", + "Profiling", + "template.type", + "TARGET", + "newLabel", + "newValue")))); */ + // } + @Test + @Order(5) + void testActiveRecordingMetadataMutation() throws Exception { + Thread.sleep(5000); + JsonObject notificationRecording = startRecording(); + Assertions.assertEquals("test", notificationRecording.getString("name")); + int id = Integer.parseInt(notificationRecording.getString("id")); + System.out.println("+++ID: " + id); + + JsonObject variables = new JsonObject(); + variables.put("recordingId", id); + JsonArray labels = new JsonArray(); + labels.add(new JsonObject().put("key", "template.name").put("value", "Profiling")); + labels.add(new JsonObject().put("key", "template.type").put("value", "TARGET")); + labels.add(new JsonObject().put("key", "newLabel").put("value", "newValue")); + labels.add(new JsonObject().put("key", "newkey").put("value", "newvalue")); + JsonObject metadataInput = new JsonObject().put("labels", labels); + variables.put("metadataInput", metadataInput); + + JsonObject query = new JsonObject(); + query.put( + "query", + "query ($metadataInput: MetadataLabelsInput!) { targetNodes { name target {" + + " activeRecordings(filter: {name: \"test\"}) { data { id" + + " doPutMetadata(metadataInput: $metadataInput) { metadata { labels { key" + + " value } } } } } } } }"); + query.put("variables", variables); + + HttpResponse resp = + webClient + .extensions() + .post("/api/v3/graphql", query.toBuffer(), REQUEST_TIMEOUT_SECONDS); MatcherAssert.assertThat( - activeRecording.metadata, - Matchers.equalTo( - RecordingMetadata.of( - Map.of( - "template.name", - "Profiling", - "template.type", - "TARGET", - "newLabel", - "newValue")))); */ + resp.statusCode(), + Matchers.both(Matchers.greaterThanOrEqualTo(200)).and(Matchers.lessThan(300))); + String jsonResponse = resp.bodyAsString(); + System.out.println("+++ActiveMutation Resp here: " + jsonResponse); + + TypeReference typeRef = + new TypeReference() {}; + ActiveMutationResponse actual = mapper.readValue(jsonResponse, typeRef); + System.out.println("+++ActualMutation Object here: " + actual.toString()); + + List targetNodes = actual.getData().getTargetNodes(); + System.out.println("+++targetNodes: " + targetNodes); + MatcherAssert.assertThat(targetNodes, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(targetNodes, Matchers.hasSize(1)); + + List activeRecordings = targetNodes.get(0).getRecordings().active.data; + System.out.println("+++activeRecordings: " + activeRecordings); + MatcherAssert.assertThat(activeRecordings, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(activeRecordings, Matchers.hasSize(1)); + + for (ActiveRecording activeRecording : activeRecordings) { + System.out.println("Active Recording Name: " + activeRecording.getName()); + List updatedLabels = activeRecording.getDoPutMetadata().getMetadata().labels; + for (KeyValue label : updatedLabels) { + System.out.println("Label Key: " + label.getKey() + ", Value: " + label.getValue()); + } + } + + deleteRecording(); } + /* + List targetNodes = actual.getData().getTargetNodes().get(0); + for (TargetNode targetNode : targetNodes) { + Assertions.assertNotNull(targetNode.getTarget()); + List recordings = targetNode.getTarget().getActiveRecordings(); + for (ActiveRecording recording : recordings) { + Assertions.assertEquals(id, recording.getId()); + RecordingMetadata metadata = recording.getDoPutMetadata().getMetadata(); + Assertions.assertNotNull(metadata); + List