2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.rest.history;
22 import static org.hamcrest.CoreMatchers.is;
23 import static org.junit.Assert.*;
25 import com.google.gson.JsonArray;
26 import com.google.gson.JsonElement;
27 import com.google.gson.JsonParser;
31 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
32 import org.janusgraph.core.JanusGraphTransaction;
33 import org.junit.Ignore;
34 import org.junit.Test;
35 import org.onap.aai.PayloadUtil;
36 import org.onap.aai.db.props.AAIProperties;
37 import org.onap.aai.dbmap.AAIGraph;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.http.HttpEntity;
41 import org.springframework.http.HttpMethod;
42 import org.springframework.http.HttpStatus;
43 import org.springframework.http.ResponseEntity;
45 @Ignore("The lifecycle format requires the history schema to be loaded. "
46 + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. "
47 + "This needs to be addressed.")
48 public class DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest
49 extends AbstractSpringHistoryRestTest {
51 private static final Logger LOGGER =
52 LoggerFactory.getLogger(DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.class);
55 public void createTestGraph() {
56 JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
57 boolean success = true;
59 GraphTraversalSource g = transaction.traversal();
62 * - created pserver @ time 100
63 * - equip-type = first-ps-type
64 * - update equip-type @ 500
65 * - equip-type = first-ps-type-update
66 * - deleted pserver @ time 1000
69 .property(AAIProperties.NODE_TYPE, "pserver", AAIProperties.SOURCE_OF_TRUTH,
70 "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT,
71 "JUNIT-D", AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 100L,
72 AAIProperties.END_TS, 1000L)
73 .property(AAIProperties.AAI_URI,
74 "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
75 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C",
76 AAIProperties.END_SOT, "JUNIT-D", AAIProperties.END_TX_ID, "JUNIT-D",
77 AAIProperties.START_TS, 100L, AAIProperties.END_TS, 1000L)
78 .property(AAIProperties.RESOURCE_VERSION, "100", AAIProperties.SOURCE_OF_TRUTH,
79 "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT,
80 "JUNIT-U", AAIProperties.END_TX_ID, "JUNIT-U", AAIProperties.START_TS, 100L,
81 AAIProperties.END_TS, 500L)
82 .property(AAIProperties.RESOURCE_VERSION, "500", AAIProperties.SOURCE_OF_TRUTH,
83 "JUNIT-U", AAIProperties.START_TX_ID, "JUNIT-U", AAIProperties.END_SOT,
84 "JUNIT-D", AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 500L,
85 AAIProperties.END_TS, 1000L)
86 .property("hostname", "test-pserver-dsl", AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
87 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT, "JUNIT-D",
88 AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 100L,
89 AAIProperties.END_TS, 1000L)
90 .property("in-maint", false, AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
91 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT, "JUNIT-D",
92 AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 100L,
93 AAIProperties.END_TS, 1000L)
94 .property("equip-type", "first-ps-type", AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
95 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT, "JUNIT-U",
96 AAIProperties.END_TX_ID, "JUNIT-U", AAIProperties.START_TS, 100L,
97 AAIProperties.END_TS, 500L)
98 .property("equip-type", "first-ps-type-update", AAIProperties.SOURCE_OF_TRUTH,
99 "JUNIT-U", AAIProperties.START_TX_ID, "JUNIT-U", AAIProperties.END_SOT,
100 "JUNIT-D", AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 500L,
101 AAIProperties.END_TS, 1000L)
102 .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C", AAIProperties.SOURCE_OF_TRUTH,
103 "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT,
104 "JUNIT-D", AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 100L,
105 AAIProperties.END_TS, 1000L)
106 .property(AAIProperties.END_SOT, "JUNIT-D", AAIProperties.SOURCE_OF_TRUTH,
107 "JUNIT-D", AAIProperties.START_TX_ID, "JUNIT-D", AAIProperties.END_SOT,
108 "JUNIT-D", AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 100L,
109 AAIProperties.END_TS, 1000L)
110 .property(AAIProperties.START_TS, 100L, AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
111 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT, "JUNIT-D",
112 AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 100L,
113 AAIProperties.END_TS, 1000L)
114 .property(AAIProperties.END_TS, 1000L, AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
115 AAIProperties.START_TX_ID, "JUNIT-D", AAIProperties.END_SOT, "JUNIT-D",
116 AAIProperties.END_TX_ID, "JUNIT-D", AAIProperties.START_TS, 1000L,
117 AAIProperties.END_TS, 1000L)
122 * - created pserver @ time 10000
123 * - equip-type = second-ps-type
124 * - delete equip-type @ 13000
125 * - recreate equip-type @ 15000
126 * - equip-type = second-ps-type-recreated
127 * - update equip-type @ 17000
128 * - equip-type = second-ps-type-update
129 * - delete equip-type @ 20000
132 .property(AAIProperties.NODE_TYPE, "pserver", AAIProperties.SOURCE_OF_TRUTH,
133 "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.START_TS, 10000L)
134 .property(AAIProperties.AAI_URI,
135 "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
136 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C",
137 AAIProperties.START_TS, 10000L)
138 .property(AAIProperties.RESOURCE_VERSION, "10000", AAIProperties.SOURCE_OF_TRUTH,
139 "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT,
140 "JUNIT-U-1", AAIProperties.END_TX_ID, "JUNIT-U-1", AAIProperties.START_TS,
141 10000L, AAIProperties.END_TS, 13000L)
142 .property(AAIProperties.RESOURCE_VERSION, "13000", AAIProperties.SOURCE_OF_TRUTH,
143 "JUNIT-U-1", AAIProperties.START_TX_ID, "JUNIT-U-1", AAIProperties.END_SOT,
144 "JUNIT-U-2", AAIProperties.END_TX_ID, "JUNIT-U-2", AAIProperties.START_TS,
145 13000L, AAIProperties.END_TS, 15000L)
146 .property(AAIProperties.RESOURCE_VERSION, "15000", AAIProperties.SOURCE_OF_TRUTH,
147 "JUNIT-U-2", AAIProperties.START_TX_ID, "JUNIT-U-2", AAIProperties.END_SOT,
148 "JUNIT-U-3", AAIProperties.END_TX_ID, "JUNIT-U-3", AAIProperties.START_TS,
149 15000L, AAIProperties.END_TS, 17000L)
150 .property(AAIProperties.RESOURCE_VERSION, "17000", AAIProperties.SOURCE_OF_TRUTH,
151 "JUNIT-U-3", AAIProperties.START_TX_ID, "JUNIT-U-3", AAIProperties.END_SOT,
152 "JUNIT-U-4", AAIProperties.END_TX_ID, "JUNIT-U-4", AAIProperties.START_TS,
153 17000L, AAIProperties.END_TS, 20000L)
154 .property(AAIProperties.RESOURCE_VERSION, "20000", AAIProperties.SOURCE_OF_TRUTH,
155 "JUNIT-U-4", AAIProperties.START_TX_ID, "JUNIT-U-4", AAIProperties.START_TS,
157 .property("hostname", "test-pserver-dsl", AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
158 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.START_TS, 10000L)
159 .property("in-maint", true, AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
160 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.START_TS, 10000L)
161 .property("equip-type", "second-ps-type", AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
162 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.END_SOT, "JUNIT-U-1",
163 AAIProperties.END_TX_ID, "JUNIT-U-1", AAIProperties.START_TS, 10000L,
164 AAIProperties.END_TS, 13000L)
165 .property("equip-type", "second-ps-type-recreated", AAIProperties.SOURCE_OF_TRUTH,
166 "JUNIT-U-2", AAIProperties.START_TX_ID, "JUNIT-U-2", AAIProperties.END_SOT,
167 "JUNIT-U-3", AAIProperties.END_TX_ID, "JUNIT-U-3", AAIProperties.START_TS,
168 15000L, AAIProperties.END_TS, 17000L)
169 .property("equip-type", "second-ps-type-update", AAIProperties.SOURCE_OF_TRUTH,
170 "JUNIT-U-3", AAIProperties.START_TX_ID, "JUNIT-U-3", AAIProperties.START_TS,
171 17000L, AAIProperties.END_SOT, "JUNIT-U-4", AAIProperties.END_TX_ID,
172 "JUNIT-U-4", AAIProperties.END_TS, 20000L)
173 .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C", AAIProperties.SOURCE_OF_TRUTH,
174 "JUNIT-C", AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.START_TS, 10000L)
175 .property(AAIProperties.START_TS, 10000L, AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
176 AAIProperties.START_TX_ID, "JUNIT-C", AAIProperties.START_TS, 10000L)
178 } catch (Exception ex) {
182 transaction.commit();
184 transaction.rollback();
185 fail("Unable to setup the graph");
190 private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
191 return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
194 private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint,
195 String additionalFilterInParen) throws Exception {
196 Map<String, String> dslQueryMap = new HashMap<>();
197 dslQueryMap.put("dsl-query",
198 "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
199 String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
200 httpEntity = new HttpEntity(payload, headers);
201 ResponseEntity responseEntity =
202 restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
203 JsonArray results = new JsonParser().parse(responseEntity.getBody().toString())
204 .getAsJsonObject().getAsJsonArray("results");
205 LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint,
206 responseEntity.getBody());
208 assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
209 assertEquals("Expected the response to be 200", HttpStatus.OK,
210 responseEntity.getStatusCode());
214 private void verifyEquipTypeValues(JsonArray results, String... expectedEquipTypes) {
215 List<String> expected = Arrays.asList(expectedEquipTypes);
216 final List<String> actualEquipType = new ArrayList<>();
217 for (JsonElement result : results) {
218 for (JsonElement property : result.getAsJsonObject().get("properties")
220 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
221 if (property.getAsJsonObject().has("value")
222 && !property.getAsJsonObject().get("value").isJsonNull()) {
223 actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
225 actualEquipType.add(null);
230 assertThat("Verify equip-type in lifecycle", actualEquipType, is(expected));
233 private void verifyEquipTypeSoTs(JsonArray results, String... expectedSTOs) {
234 List<String> expected = Arrays.asList(expectedSTOs);
235 final List<String> actualEquipType = new ArrayList<>();
236 for (JsonElement result : results) {
237 for (JsonElement property : result.getAsJsonObject().get("properties")
239 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
240 if (property.getAsJsonObject().has("sot")
241 && !property.getAsJsonObject().get("sot").isJsonNull()) {
242 actualEquipType.add(property.getAsJsonObject().get("sot").getAsString());
244 actualEquipType.add(null);
249 assertThat("Verify equip-type SoTs in lifecycle", actualEquipType, is(expected));
252 private void verifyEquipTypeTxId(JsonArray results, String... expectedSTOs) {
253 List<String> expected = Arrays.asList(expectedSTOs);
254 final List<String> actualEquipType = new ArrayList<>();
255 for (JsonElement result : results) {
256 for (JsonElement property : result.getAsJsonObject().get("properties")
258 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
259 if (property.getAsJsonObject().has("tx-id")
260 && !property.getAsJsonObject().get("tx-id").isJsonNull()) {
261 actualEquipType.add(property.getAsJsonObject().get("tx-id").getAsString());
263 actualEquipType.add(null);
268 assertThat("Verify equip-type tx-ids in lifecycle", actualEquipType, is(expected));
271 private void verifyEquipTypeTimestamps(JsonArray results, Long... expectedSTOs) {
272 List<Long> expected = Arrays.asList(expectedSTOs);
273 final List<Long> actualEquipType = new ArrayList<>();
274 for (JsonElement result : results) {
275 for (JsonElement property : result.getAsJsonObject().get("properties")
277 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
278 if (property.getAsJsonObject().has("timestamp")
279 && !property.getAsJsonObject().get("timestamp").isJsonNull()) {
281 .add(property.getAsJsonObject().get("timestamp").getAsLong());
283 actualEquipType.add(null);
288 assertThat("Verify equip-type timestamps in lifecycle", actualEquipType, is(expected));
291 private void verifyNodeTimestamps(JsonArray results, Long... nodeTimestamps) {
292 List<Long> expected = Arrays.asList(nodeTimestamps);
293 final List<Long> actualEquipType = new ArrayList<>();
294 for (JsonElement result : results) {
295 result.getAsJsonObject().get("node-actions").getAsJsonArray()
296 .forEach(jsonElement -> actualEquipType
297 .add(jsonElement.getAsJsonObject().get("timestamp").getAsLong()));
299 assertThat("Verify node-changes timestamps in lifecycle", actualEquipType, is(expected));
302 private void verifyNodeSot(JsonArray results, String... nodeSots) {
303 List<String> expected = Arrays.asList(nodeSots);
304 final List<String> actualEquipType = new ArrayList<>();
305 for (JsonElement result : results) {
306 result.getAsJsonObject().get("node-actions").getAsJsonArray()
307 .forEach(jsonElement -> actualEquipType
308 .add(jsonElement.getAsJsonObject().get("sot").getAsString()));
310 assertThat("Verify node-changes sot in lifecycle", actualEquipType, is(expected));
314 public void lifecycleQueryNoStartOrEndTsTest() throws Exception {
316 String endpoint = "/aai/v14/dsl?format=lifecycle";
317 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
318 assertEquals("Result size", 1, results.size());
320 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
321 null, "second-ps-type", "first-ps-type-update", "first-ps-type");
322 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
323 "JUNIT-U", "JUNIT-C");
324 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
325 "JUNIT-U", "JUNIT-C");
326 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
327 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
329 String equipType = "first-ps-type";
330 results = getResultsForPserverLookupByHostnameAndAnother(endpoint,
331 "('equip-type','" + equipType + "')");
332 assertEquals("Filter equip-type on " + equipType, 1, results.size());
333 verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
334 verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
335 verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
336 verifyEquipTypeTimestamps(results, 500L, 100L);
337 verifyNodeTimestamps(results, 1000L, 100L);
339 equipType = "second-ps-type-recreated";
340 results = getResultsForPserverLookupByHostnameAndAnother(endpoint,
341 "('equip-type','" + equipType + "')");
342 assertEquals("Filter equip-type on " + equipType, 1, results.size());
343 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
344 null, "second-ps-type");
345 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
346 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
347 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
348 verifyNodeTimestamps(results, 10000L);
352 public void lifecycleQueryStartTsBeforeCreationTimeTest() throws Exception {
354 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50";
355 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
356 assertEquals("Result size", 1, results.size());
358 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
359 null, "second-ps-type", "first-ps-type-update", "first-ps-type");
360 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
361 "JUNIT-U", "JUNIT-C");
362 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
363 "JUNIT-U", "JUNIT-C");
364 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
365 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
367 String equipType = "first-ps-type";
368 results = getResultsForPserverLookupByHostnameAndAnother(endpoint,
369 "('equip-type','" + equipType + "')");
370 assertEquals("Filter equip-type on " + equipType, 1, results.size());
371 verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
372 verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
373 verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
374 verifyEquipTypeTimestamps(results, 500L, 100L);
375 verifyNodeTimestamps(results, 1000L, 100L);
377 equipType = "second-ps-type-recreated";
378 results = getResultsForPserverLookupByHostnameAndAnother(endpoint,
379 "('equip-type','" + equipType + "')");
380 assertEquals("Filter equip-type on " + equipType, 1, results.size());
381 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
382 null, "second-ps-type");
383 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
384 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
385 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
386 verifyNodeTimestamps(results, 10000L);
390 public void lifecycleQueryStartTsAtCreationTimeTest() throws Exception {
392 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=100";
393 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
394 assertEquals("Result size", 1, results.size());
396 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
397 null, "second-ps-type", "first-ps-type-update", "first-ps-type");
398 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
399 "JUNIT-U", "JUNIT-C");
400 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
401 "JUNIT-U", "JUNIT-C");
402 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
403 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
407 public void lifecycleQueryStartTsAfterCreationTimeTest() throws Exception {
409 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=300";
410 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
411 assertEquals("Result size", 1, results.size());
413 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
414 null, "second-ps-type", "first-ps-type-update");
415 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
417 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
419 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L);
420 verifyNodeTimestamps(results, 10000L, 1000L);
424 public void lifecycleQueryStartTsAtFirstUpdateTimeTest() throws Exception {
426 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=500";
427 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
428 assertEquals("Result size", 1, results.size());
430 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
431 null, "second-ps-type", "first-ps-type-update");
432 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
434 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
436 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L);
437 verifyNodeTimestamps(results, 10000L, 1000L);
441 public void lifecycleQueryStartTsAfterFirstUpdateTimeTest() throws Exception {
443 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=700";
444 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
445 assertEquals("Result size", 1, results.size());
447 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
448 null, "second-ps-type");
449 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
450 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
451 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
452 verifyNodeTimestamps(results, 10000L, 1000L);
456 public void lifecycleQueryStartTsAtFirstDeleteTimeTest() throws Exception {
458 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=1000";
459 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
460 assertEquals("Result size", 1, results.size());
462 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
463 null, "second-ps-type");
464 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
465 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
466 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
467 verifyNodeTimestamps(results, 10000L, 1000L);
471 public void lifecycleQueryStartTsAfterFirstDeleteTimeTest() throws Exception {
473 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=5000";
474 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
475 assertEquals("Result size", 1, results.size());
477 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
478 null, "second-ps-type");
479 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
480 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
481 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
482 verifyNodeTimestamps(results, 10000L);
486 public void lifecycleQueryStartTsAtSecondCreateTimeTest() throws Exception {
488 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=10000";
489 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
490 assertEquals("Result size", 1, results.size());
492 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
493 null, "second-ps-type");
494 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
495 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
496 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
497 verifyNodeTimestamps(results, 10000L);
501 public void lifecycleQueryStartTsAfterSecondCreateTimeTest() throws Exception {
503 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=12000";
504 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
505 assertEquals("Result size", 1, results.size());
507 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
509 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
510 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
511 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L);
512 verifyNodeTimestamps(results);
516 public void lifecycleQueryStartTsAtEquipTypeFirstDeleteOnSecondPsTimeTest() throws Exception {
518 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=13000";
519 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
520 assertEquals("Result size", 1, results.size());
522 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
524 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
525 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
526 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L);
527 verifyNodeTimestamps(results);
531 public void lifecycleQueryStartTsAfterEquipTypeFirstDeleteOnSecondPsTimeTest()
534 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=14000";
535 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
536 assertEquals("Result size", 1, results.size());
538 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated");
539 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
540 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
541 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L);
542 verifyNodeTimestamps(results);
546 public void lifecycleQueryStartTsAtEquipTypeRecreateOnSecondPsTimeTest() throws Exception {
548 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=15000";
549 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
550 assertEquals("Result size", 1, results.size());
552 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated");
553 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
554 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
555 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L);
556 verifyNodeTimestamps(results);
560 public void lifecycleQueryStartTsAfterEquipTypeRecreateOnSecondPsTimeTest() throws Exception {
562 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=16000";
563 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
564 assertEquals("Result size", 1, results.size());
566 verifyEquipTypeValues(results, null, "second-ps-type-update");
567 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3");
568 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3");
569 verifyEquipTypeTimestamps(results, 20000L, 17000L);
570 verifyNodeTimestamps(results);
574 public void lifecycleQueryStartTsAtEquipTypeUpdateOnSecondPsTimeTest() throws Exception {
576 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=17000";
577 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
578 assertEquals("Result size", 1, results.size());
580 verifyEquipTypeValues(results, null, "second-ps-type-update");
581 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3");
582 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3");
583 verifyEquipTypeTimestamps(results, 20000L, 17000L);
584 verifyNodeTimestamps(results);
588 public void lifecycleQueryStartTsAfterEquipTypeUpdateOnSecondPsTimeTest() throws Exception {
590 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=19000";
591 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
592 assertEquals("Result size", 1, results.size());
594 verifyEquipTypeValues(results, new String[] {null});
595 verifyEquipTypeSoTs(results, "JUNIT-U-4");
596 verifyEquipTypeTxId(results, "JUNIT-U-4");
597 verifyEquipTypeTimestamps(results, 20000L);
598 verifyNodeTimestamps(results);
602 public void lifecycleQueryStartTsOnEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
604 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=20000";
605 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
606 assertEquals("Result size", 1, results.size());
608 verifyEquipTypeValues(results, new String[] {null});
609 verifyEquipTypeSoTs(results, "JUNIT-U-4");
610 verifyEquipTypeTxId(results, "JUNIT-U-4");
611 verifyEquipTypeTimestamps(results, 20000L);
612 verifyNodeTimestamps(results);
616 public void lifecycleQueryStartTsAfterEquipTypeSecondDeleteOnSecondPsTimeTest()
619 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=22000";
620 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
621 assertEquals("Result size", 0, results.size());
623 verifyEquipTypeValues(results);
624 verifyEquipTypeSoTs(results);
625 verifyEquipTypeTxId(results);
626 verifyEquipTypeTimestamps(results);
627 verifyNodeTimestamps(results);
631 public void lifecycleQueryStartTsBeforeCreationEndTimeAfterEquipTypeSecondDeleteOnSecondPsTimeTest()
634 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=22000";
635 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
636 assertEquals("Result size", 1, results.size());
638 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
639 null, "second-ps-type", "first-ps-type-update", "first-ps-type");
640 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
641 "JUNIT-U", "JUNIT-C");
642 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
643 "JUNIT-U", "JUNIT-C");
644 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
645 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
649 public void lifecycleQueryStartTsBeforeCreationEndTimeAtEquipTypeSecondDeleteOnSecondPsTimeTest()
652 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=20000";
653 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
654 assertEquals("Result size", 1, results.size());
656 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated",
657 null, "second-ps-type", "first-ps-type-update", "first-ps-type");
658 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
659 "JUNIT-U", "JUNIT-C");
660 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C",
661 "JUNIT-U", "JUNIT-C");
662 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
663 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
667 public void lifecycleQueryStartTsBeforeCreationEndTimeBeforeEquipTypeSecondDeleteOnSecondPsTimeTest()
670 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=19000";
671 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
672 assertEquals("Result size", 1, results.size());
674 verifyEquipTypeValues(results, "second-ps-type-update", "second-ps-type-recreated", null,
675 "second-ps-type", "first-ps-type-update", "first-ps-type");
676 verifyEquipTypeSoTs(results, "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U",
678 verifyEquipTypeTxId(results, "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U",
680 verifyEquipTypeTimestamps(results, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
681 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
685 public void lifecycleQueryStartTsBeforeCreationEndTimeBeforeSecondPsCreateTimeTest()
688 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=9000";
689 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
690 assertEquals("Result size", 1, results.size());
692 verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
693 verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
694 verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
695 verifyEquipTypeTimestamps(results, 500L, 100L);
696 verifyNodeTimestamps(results, 1000L, 100L);
700 public void verifyNodeActionsWithNoTimeRangeTest() throws Exception {
702 String endpoint = "/aai/v14/dsl?format=lifecycle";
703 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
704 assertEquals("Result size", 1, results.size());
705 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
706 verifyNodeSot(results, "JUNIT-C", "JUNIT-D", "JUNIT-C");