|
2 | 2 |
|
3 | 3 | import com.google.gson.JsonArray; |
4 | 4 | import com.google.gson.JsonObject; |
| 5 | +import com.google.gson.JsonPrimitive; |
5 | 6 | import org.junit.Before; |
6 | 7 | import org.junit.Test; |
7 | 8 |
|
@@ -37,67 +38,34 @@ public void SetUp() |
37 | 38 | } |
38 | 39 |
|
39 | 40 | @Test |
40 | | - public void shouldReturnEnvironmentsArrayInJsonObjectWhenEmpty() |
| 41 | + public void shouldReturnTargetVersion() |
41 | 42 | { |
42 | 43 | JsonObject jsonObject = jsonCollection.getJsonObject(); |
43 | | - assertThat(jsonObject.get("environments") instanceof JsonArray,is(true)); |
44 | | - assertThat(jsonObject.getAsJsonArray("environments"), is(new JsonArray())); |
| 44 | + assertThat(jsonObject.get("target_version") instanceof JsonPrimitive,is(true)); |
| 45 | + assertThat(jsonObject.getAsJsonPrimitive("target_version").getAsInt(), is(1)); |
45 | 46 | } |
46 | 47 |
|
47 | 48 | @Test |
48 | | - public void shouldReturnGroupsArrayInJsonObjectWhenEmpty() |
| 49 | + public void shouldReturnEnvironmentsArrayInJsonObjectWhenEmpty() |
49 | 50 | { |
50 | 51 | JsonObject jsonObject = jsonCollection.getJsonObject(); |
51 | | - assertThat(jsonObject.get("groups") instanceof JsonArray,is(true)); |
52 | | - assertThat(jsonObject.getAsJsonArray("groups"), is(new JsonArray())); |
| 52 | + assertThat(jsonObject.get("environments") instanceof JsonArray,is(true)); |
| 53 | + assertThat(jsonObject.getAsJsonArray("environments"), is(new JsonArray())); |
53 | 54 | } |
54 | 55 |
|
55 | 56 | @Test |
56 | | - public void shouldAddPipelinesToDefaultGroup() |
| 57 | + public void shouldAppendPipelinesToPipelinesCollection() |
57 | 58 | { |
58 | | - jsonCollection.addPipeline(pipe1); |
59 | | - assertThat(jsonCollection.getOrCreateDefaultGroupPipelines().size(), is(1)); |
60 | | - } |
61 | | - @Test |
62 | | - public void shouldAppendDefaultGroupToGroupsInJsonObject() |
63 | | - { |
64 | | - jsonCollection.addPipeline(pipe1); |
| 59 | + jsonCollection.addPipeline(pipe1,"pipe1.json"); |
| 60 | + jsonCollection.addPipeline(pipe2,"pipe2.json"); |
65 | 61 | JsonObject jsonObject = jsonCollection.getJsonObject(); |
66 | | - assertThat(jsonObject.getAsJsonArray("groups").size(),is(1)); |
67 | | - } |
68 | | - @Test |
69 | | - public void shouldAppendOnlyOnceDefaultGroupToGroupsInJsonObjectWhen2PipelinesAdded() |
70 | | - { |
71 | | - jsonCollection.addPipeline(pipe1); |
72 | | - jsonCollection.addPipeline(pipe2); |
73 | | - JsonObject jsonObject = jsonCollection.getJsonObject(); |
74 | | - assertThat(jsonObject.getAsJsonArray("groups").size(),is(1)); |
75 | | - } |
76 | | - @Test |
77 | | - public void shouldAddPipelinesToNonDefaultGroupWhenGroupProperty() |
78 | | - { |
79 | | - jsonCollection.addPipeline(pipeInGroup); |
80 | | - JsonArray pipelines = jsonCollection.getOrCreateGroupPipelines("mygroup"); |
81 | | - assertThat(pipelines.size(),is(1)); |
82 | | - } |
83 | | - |
84 | | - @Test |
85 | | - public void shouldReturnPipelinesInDefaultGroupInJsonObject() |
86 | | - { |
87 | | - jsonCollection.addPipeline(pipe1); |
88 | | - jsonCollection.addPipeline(pipe2); |
89 | | - JsonObject jsonObject = jsonCollection.getJsonObject(); |
90 | | - |
91 | | - JsonArray pipelinesInDefault = jsonObject.getAsJsonArray("groups").get(0).getAsJsonObject().getAsJsonArray("pipelines"); |
92 | | - assertThat(pipelinesInDefault.size(),is(2)); |
93 | | - assertThat(pipelinesInDefault,hasItem(pipe1)); |
94 | | - assertThat(pipelinesInDefault,hasItem(pipe2)); |
| 62 | + assertThat(jsonObject.getAsJsonArray("pipelines").size(),is(2)); |
95 | 63 | } |
96 | 64 |
|
97 | 65 | @Test |
98 | 66 | public void shouldReturnEnvironmentsInJsonObject() |
99 | 67 | { |
100 | | - jsonCollection.addEnvironment(devEnv); |
| 68 | + jsonCollection.addEnvironment(devEnv,"dev.json"); |
101 | 69 | JsonObject jsonObject = jsonCollection.getJsonObject(); |
102 | 70 | assertThat(jsonObject.getAsJsonArray("environments").size(),is(1)); |
103 | 71 | } |
|
0 commit comments