diff options
Diffstat (limited to 'controller-server')
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 |