From 2a9fef2d14bb4735ad59244f1af8a7b6971fd8f8 Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Mon, 22 Jun 2020 16:58:28 +0200 Subject: Move unit test to same location as class being tested --- .../ai/vespa/hosted/api/TestDescriptorTest.java | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java (limited to 'hosted-api/src/test') diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java new file mode 100644 index 00000000000..2676d9d79da --- /dev/null +++ b/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java @@ -0,0 +1,70 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package ai.vespa.hosted.api; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Collections; +import java.util.List; + +/** + * @author mortent + */ +public class TestDescriptorTest { + + @Test + public void parses_system_test_only () { + String testDescriptor = "{\n" + + " \"version\": \"1.0\",\n" + + " \"configuredTests\": {\n" + + " \"systemTests\": [\n" + + " \"ai.vespa.test.SystemTest1\",\n" + + " \"ai.vespa.test.SystemTest2\"\n" + + " ]\n" + + " " + + "}\n" + + "}"; + var testClassDescriptor = TestDescriptor.fromJsonString(testDescriptor); + + var systemTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.systemtest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.SystemTest1", "ai.vespa.test.SystemTest2"), systemTests); + + var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); + Assertions.assertIterableEquals(Collections.emptyList(), stagingTests); + + var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest); + Assertions.assertIterableEquals(Collections.emptyList(), productionTests); + } + + @Test + public void parsesDescriptorFile() { + String testDescriptor = "{\n" + + " \"version\": \"1.0\",\n" + + " \"configuredTests\": {\n" + + " \"systemTests\": [\n" + + " \"ai.vespa.test.SystemTest1\",\n" + + " \"ai.vespa.test.SystemTest2\"\n" + + " ],\n" + + " \"stagingTests\": [\n" + + " \"ai.vespa.test.StagingTest1\",\n" + + " \"ai.vespa.test.StagingTest2\"\n" + + " ],\n" + + " \"productionTests\": [\n" + + " \"ai.vespa.test.ProductionTest1\",\n" + + " \"ai.vespa.test.ProductionTest2\"\n" + + " ]\n" + + " " + + "}\n" + + "}"; + var testClassDescriptor = TestDescriptor.fromJsonString(testDescriptor); + + var systemTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.systemtest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.SystemTest1", "ai.vespa.test.SystemTest2"), systemTests); + + var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.StagingTest1", "ai.vespa.test.StagingTest2"), stagingTests); + + var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.ProductionTest1", "ai.vespa.test.ProductionTest2"), productionTests); + } +} -- cgit v1.2.3