1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.api;
import com.yahoo.test.json.JsonTestHelper;
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 stagingSetupTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest);
Assertions.assertIterableEquals(Collections.emptyList(), stagingSetupTests);
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" +
" \"stagingSetupTests\": [\n" +
" \"ai.vespa.test.StagingSetupTest1\",\n" +
" \"ai.vespa.test.StagingSetupTest2\"\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 stagingSetupTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingsetuptest);
Assertions.assertIterableEquals(List.of("ai.vespa.test.StagingSetupTest1", "ai.vespa.test.StagingSetupTest2"), stagingSetupTests);
var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest);
Assertions.assertIterableEquals(List.of("ai.vespa.test.ProductionTest1", "ai.vespa.test.ProductionTest2"), productionTests);
JsonTestHelper.assertJsonEquals(testClassDescriptor.toJson(), testDescriptor);
}
@Test
public void generatesCorrectJson() {
String json = "{\n" +
" \"version\": \"1.0\",\n" +
" \"configuredTests\": {\n" +
" \"systemTests\": [\n" +
" \"ai.vespa.test.SystemTest1\",\n" +
" \"ai.vespa.test.SystemTest2\"\n" +
" ]\n" +
" " +
" }\n" +
"}\n";
var descriptor = TestDescriptor.fromJsonString(json);
JsonTestHelper.assertJsonEquals(json, descriptor.toJson());
}
}
|