diff options
Diffstat (limited to 'configserver-flags')
-rw-r--r-- | configserver-flags/pom.xml | 5 | ||||
-rw-r--r-- | configserver-flags/src/test/java/com/yahoo/vespa/configserver/flags/http/FlagsHandlerTest.java | 101 |
2 files changed, 52 insertions, 54 deletions
diff --git a/configserver-flags/pom.xml b/configserver-flags/pom.xml index 63525805669..02824f2e6e3 100644 --- a/configserver-flags/pom.xml +++ b/configserver-flags/pom.xml @@ -110,11 +110,6 @@ <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> <plugins> diff --git a/configserver-flags/src/test/java/com/yahoo/vespa/configserver/flags/http/FlagsHandlerTest.java b/configserver-flags/src/test/java/com/yahoo/vespa/configserver/flags/http/FlagsHandlerTest.java index 2700ab114e9..3c4c99e0337 100644 --- a/configserver-flags/src/test/java/com/yahoo/vespa/configserver/flags/http/FlagsHandlerTest.java +++ b/configserver-flags/src/test/java/com/yahoo/vespa/configserver/flags/http/FlagsHandlerTest.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author hakonhall @@ -36,8 +36,6 @@ public class FlagsHandlerTest { "id2", true, List.of("joe"), "2010-01-01", "2030-01-01", "desc2", "mod2", FetchVector.Dimension.HOSTNAME, FetchVector.Dimension.APPLICATION_ID); - private static final String FLAGS_V1_URL = "https://foo.com:4443/flags/v1"; - private final FlagsDb flagsDb = new FlagsDbImpl(new MockCurator()); private final FlagsHandler handler = new FlagsHandler(FlagsHandler.testContext(), flagsDb); @@ -71,14 +69,15 @@ public class FlagsHandlerTest { void testData() { // PUT flag with ID id1 verifySuccessfulRequest(Method.PUT, "/data/" + FLAG1.id(), - "{\n" + - " \"id\": \"id1\",\n" + - " \"rules\": [\n" + - " {\n" + - " \"value\": true\n" + - " }\n" + - " ]\n" + - "}", + """ + { + "id": "id1", + "rules": [ + { + "value": true + } + ] + }""", ""); // GET on ID id1 should return the same as the put. @@ -99,29 +98,31 @@ public class FlagsHandlerTest { // PUT id2 verifySuccessfulRequest(Method.PUT, "/data/" + FLAG2.id(), - "{\n" + - " \"id\": \"id2\",\n" + - " \"rules\": [\n" + - " {\n" + - " \"conditions\": [\n" + - " {\n" + - " \"type\": \"whitelist\",\n" + - " \"dimension\": \"hostname\",\n" + - " \"values\": [ \"host1\", \"host2\" ]\n" + - " },\n" + - " {\n" + - " \"type\": \"blacklist\",\n" + - " \"dimension\": \"application\",\n" + - " \"values\": [ \"app1\", \"app2\" ]\n" + - " }\n" + - " ],\n" + - " \"value\": true\n" + - " }\n" + - " ],\n" + - " \"attributes\": {\n" + - " \"zone\": \"zone1\"\n" + - " }\n" + - "}\n", + """ + { + "id": "id2", + "rules": [ + { + "conditions": [ + { + "type": "whitelist", + "dimension": "hostname", + "values": [ "host1", "host2" ] + }, + { + "type": "blacklist", + "dimension": "application", + "values": [ "app1", "app2" ] + } + ], + "value": true + } + ], + "attributes": { + "zone": "zone1" + } + } + """, ""); // GET on id2 should now return what was put @@ -135,14 +136,16 @@ public class FlagsHandlerTest { // Putting (overriding) id1 should work silently verifySuccessfulRequest(Method.PUT, "/data/" + FLAG1.id(), - "{\n" + - " \"id\": \"id1\",\n" + - " \"rules\": [\n" + - " {\n" + - " \"value\": false\n" + - " }\n" + - " ]\n" + - "}\n", + """ + { + "id": "id1", + "rules": [ + { + "value": false + } + ] + } + """, ""); // Verify PUT @@ -162,16 +165,16 @@ public class FlagsHandlerTest { @Test void testForcing() { - assertThat(handle(Method.PUT, "/data/" + new FlagId("undef"), "", 400)).contains("There is no flag 'undef'"); + assertTrue(handle(Method.PUT, "/data/" + new FlagId("undef"), "", 400).contains("There is no flag 'undef'")); - assertThat(handle(Method.PUT, "/data/" + new FlagId("undef") + "?force=true", "", 400)). - contains("No content to map due to end-of-input"); + assertTrue(handle(Method.PUT, "/data/" + new FlagId("undef") + "?force=true", "", 400). + contains("No content to map due to end-of-input")); - assertThat(handle(Method.PUT, "/data/" + FLAG1.id(), "{}", 400)). - contains("Flag ID missing"); + assertTrue(handle(Method.PUT, "/data/" + FLAG1.id(), "{}", 400). + contains("Flag ID missing")); - assertThat(handle(Method.PUT, "/data/" + FLAG1.id(), "{\"id\": \"id1\",\"rules\": [{\"value\":\"string\"}]}", 400)). - contains("Wrong type of JsonNode: STRING"); + assertTrue(handle(Method.PUT, "/data/" + FLAG1.id(), "{\"id\": \"id1\",\"rules\": [{\"value\":\"string\"}]}", 400). + contains("Wrong type of JsonNode: STRING")); assertEquals(handle(Method.PUT, "/data/" + FLAG1.id() + "?force=true", "{\"id\": \"id1\",\"rules\": [{\"value\":\"string\"}]}", 200), ""); |