summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-11-27 14:24:03 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-11-27 15:24:45 +0100
commitbfe5babce39d133915b1119cf87e3faa527396f2 (patch)
tree345841adfc4ab4ac992e89dd684d935806219b90 /controller-server
parent003b39e874d19b6c5d8b01c0702077c65e3b8ee3 (diff)
Fix bug in wire conversion
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResult.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResultTest.java36
2 files changed, 38 insertions, 0 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResult.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResult.java
index 3809bf6b400..bca7b18c284 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResult.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResult.java
@@ -74,6 +74,7 @@ class SystemFlagsDeployResult {
wireChange.targets = change.targets().stream().map(FlagsTarget::asString).collect(toList());
wireChange.data = change.data().map(FlagData::toWire).orElse(null);
wireChange.previousData = change.previousData().map(FlagData::toWire).orElse(null);
+ wireResult.changes.add(wireChange);
}
wireResult.errors = new ArrayList<>();
for (OperationError error : errors) {
@@ -83,6 +84,7 @@ class SystemFlagsDeployResult {
wireError.target = error.target().asString();
wireError.flagId = error.flagId().map(FlagId::toString).orElse(null);
wireError.data = error.flagData().map(FlagData::toWire).orElse(null);
+ wireResult.errors.add(wireError);
}
return wireResult;
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResultTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResultTest.java
new file mode 100644
index 00000000000..0bbc0c97cf6
--- /dev/null
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsDeployResultTest.java
@@ -0,0 +1,36 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.controller.restapi.systemflags;
+
+import com.yahoo.config.provision.SystemName;
+import com.yahoo.vespa.flags.FlagId;
+import com.yahoo.vespa.hosted.controller.api.systemflags.v1.FlagsTarget;
+import com.yahoo.vespa.hosted.controller.api.systemflags.v1.wire.WireSystemFlagsDeployResult;
+import org.junit.Test;
+
+import java.util.List;
+
+import static com.yahoo.vespa.hosted.controller.restapi.systemflags.SystemFlagsDeployResult.*;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author bjorncs
+ */
+public class SystemFlagsDeployResultTest {
+ @Test
+ public void changes_and_errors_are_present_in_wire_format() {
+ FlagsTarget controllerTarget = FlagsTarget.forController(SystemName.cd);
+ FlagId flagOne = new FlagId("flagone");
+ FlagId flagTwo = new FlagId("flagtwo");
+ SystemFlagsDeployResult result = new SystemFlagsDeployResult(
+ List.of(
+ FlagDataChange.deleted(flagOne, controllerTarget)),
+ List.of(
+ OperationError.deleteFailed("delete failed", controllerTarget, flagTwo)));
+ WireSystemFlagsDeployResult wire = result.toWire();
+
+ assertThat(wire.changes).hasSize(1);
+ assertThat(wire.changes.get(0).flagId).isEqualTo(flagOne.toString());
+ assertThat(wire.errors).hasSize(1);
+ assertThat(wire.errors.get(0).flagId).isEqualTo(flagTwo.toString());
+ }
+} \ No newline at end of file