diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-05-31 11:22:21 +0200 |
---|---|---|
committer | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-05-31 11:22:21 +0200 |
commit | 50e94e6fd2b8940054ec94779225c89eeeafd53d (patch) | |
tree | a24db037a6c35ae1c8ae36344c70c51a925d9235 /controller-server | |
parent | f0c78fa139c408cf59052cc83933215416d67d3e (diff) |
Add test for handling both rotation and rotations
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java index 7b89b77d105..1269db0d42c 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java @@ -29,6 +29,7 @@ import com.yahoo.vespa.hosted.controller.application.RotationStatus; import com.yahoo.vespa.hosted.controller.rotation.RotationId; import org.junit.Test; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -244,4 +245,32 @@ public class ApplicationSerializerTest { // ok if no error } + /** TODO: Test can be removed after June 2019 - once legacy field for single rotation is retired */ + @Test + public void testParsingLegacyRotationElement() throws IOException { + // Use the 'complete-application.json' as a baseline + final var applicationJson = Files.readAllBytes(testData.resolve("complete-application.json")); + final var slime = SlimeUtils.jsonToSlime(applicationJson); + + // Add the necessary fields to the Slime representation of the application + final var cursor = slime.get(); + + cursor.setString("rotation", "single-rotation"); + + final var rotations = cursor.setArray("rotations"); + rotations.addString("multiple-rotation-1"); + rotations.addString("multiple-rotation-2"); + + // Parse and test the output from parsing contains both legacy rotation and multiple rotations + final var application = applicationSerializer.fromSlime(slime); + + assertEquals( + List.of( + new RotationId("multiple-rotation-1"), + new RotationId("multiple-rotation-2"), + new RotationId("single-rotation") + ), + application.rotations() + ); + } } |