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 com.google.gson.JsonArray;
23 import com.google.gson.JsonElement;
24 import com.google.gson.JsonParser;
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
26 import org.janusgraph.core.JanusGraphTransaction;
27 import org.junit.Ignore;
28 import org.junit.Test;
29 import org.onap.aai.PayloadUtil;
30 import org.onap.aai.db.props.AAIProperties;
31 import org.onap.aai.dbmap.AAIGraph;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.http.HttpEntity;
35 import org.springframework.http.HttpMethod;
36 import org.springframework.http.HttpStatus;
37 import org.springframework.http.ResponseEntity;
41 import static org.hamcrest.CoreMatchers.is;
42 import static org.junit.Assert.*;
44 @Ignore("The lifecycle format requires the history schema to be loaded. " +
45 "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
46 "This needs to be addressed.")
47 public class DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest extends AbstractSpringHistoryRestTest {
49 private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.class);
52 public void createTestGraph() {
53 JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
54 boolean success = true;
56 GraphTraversalSource g = transaction.traversal();
59 - created pserver @ time 100
60 - equip-type = first-ps-type
61 - update equip-type @ 500
62 - equip-type = first-ps-type-update
63 - deleted pserver @ time 1000
65 g.addV().property(AAIProperties.NODE_TYPE, "pserver",
66 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
67 AAIProperties.START_TX_ID, "JUNIT-C",
68 AAIProperties.END_SOT, "JUNIT-D",
69 AAIProperties.END_TX_ID, "JUNIT-D",
70 AAIProperties.START_TS, 100L,
71 AAIProperties.END_TS, 1000L
73 .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
74 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
75 AAIProperties.START_TX_ID, "JUNIT-C",
76 AAIProperties.END_SOT, "JUNIT-D",
77 AAIProperties.END_TX_ID, "JUNIT-D",
78 AAIProperties.START_TS, 100L,
79 AAIProperties.END_TS, 1000L
81 .property(AAIProperties.RESOURCE_VERSION, "100",
82 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
83 AAIProperties.START_TX_ID, "JUNIT-C",
84 AAIProperties.END_SOT, "JUNIT-U",
85 AAIProperties.END_TX_ID, "JUNIT-U",
86 AAIProperties.START_TS, 100L,
87 AAIProperties.END_TS, 500L
89 .property(AAIProperties.RESOURCE_VERSION, "500",
90 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
91 AAIProperties.START_TX_ID, "JUNIT-U",
92 AAIProperties.END_SOT, "JUNIT-D",
93 AAIProperties.END_TX_ID, "JUNIT-D",
94 AAIProperties.START_TS, 500L,
95 AAIProperties.END_TS, 1000L
97 .property("hostname", "test-pserver-dsl",
98 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
99 AAIProperties.START_TX_ID, "JUNIT-C",
100 AAIProperties.END_SOT, "JUNIT-D",
101 AAIProperties.END_TX_ID, "JUNIT-D",
102 AAIProperties.START_TS, 100L,
103 AAIProperties.END_TS, 1000L
105 .property("in-maint", false,
106 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
107 AAIProperties.START_TX_ID, "JUNIT-C",
108 AAIProperties.END_SOT, "JUNIT-D",
109 AAIProperties.END_TX_ID, "JUNIT-D",
110 AAIProperties.START_TS, 100L,
111 AAIProperties.END_TS, 1000L
113 .property("equip-type", "first-ps-type",
114 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
115 AAIProperties.START_TX_ID, "JUNIT-C",
116 AAIProperties.END_SOT, "JUNIT-U",
117 AAIProperties.END_TX_ID, "JUNIT-U",
118 AAIProperties.START_TS, 100L,
119 AAIProperties.END_TS, 500L
121 .property("equip-type", "first-ps-type-update",
122 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
123 AAIProperties.START_TX_ID, "JUNIT-U",
124 AAIProperties.END_SOT, "JUNIT-D",
125 AAIProperties.END_TX_ID, "JUNIT-D",
126 AAIProperties.START_TS, 500L,
127 AAIProperties.END_TS, 1000L
129 .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
130 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
131 AAIProperties.START_TX_ID, "JUNIT-C",
132 AAIProperties.END_SOT, "JUNIT-D",
133 AAIProperties.END_TX_ID, "JUNIT-D",
134 AAIProperties.START_TS, 100L,
135 AAIProperties.END_TS, 1000L
137 .property(AAIProperties.END_SOT, "JUNIT-D",
138 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
139 AAIProperties.START_TX_ID, "JUNIT-D",
140 AAIProperties.END_SOT, "JUNIT-D",
141 AAIProperties.END_TX_ID, "JUNIT-D",
142 AAIProperties.START_TS, 100L,
143 AAIProperties.END_TS, 1000L
145 .property(AAIProperties.START_TS, 100L,
146 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
147 AAIProperties.START_TX_ID, "JUNIT-C",
148 AAIProperties.END_SOT, "JUNIT-D",
149 AAIProperties.END_TX_ID, "JUNIT-D",
150 AAIProperties.START_TS, 100L,
151 AAIProperties.END_TS, 1000L
153 .property(AAIProperties.END_TS, 1000L,
154 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
155 AAIProperties.START_TX_ID, "JUNIT-D",
156 AAIProperties.END_SOT, "JUNIT-D",
157 AAIProperties.END_TX_ID, "JUNIT-D",
158 AAIProperties.START_TS, 1000L,
159 AAIProperties.END_TS, 1000L
165 - created pserver @ time 10000
166 - equip-type = second-ps-type
167 - delete equip-type @ 13000
168 - recreate equip-type @ 15000
169 - equip-type = second-ps-type-recreated
170 - update equip-type @ 17000
171 - equip-type = second-ps-type-update
172 - delete equip-type @ 20000
174 g.addV().property(AAIProperties.NODE_TYPE, "pserver",
175 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
176 AAIProperties.START_TX_ID, "JUNIT-C",
177 AAIProperties.START_TS, 10000L
179 .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
180 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
181 AAIProperties.START_TX_ID, "JUNIT-C",
182 AAIProperties.START_TS, 10000L
184 .property(AAIProperties.RESOURCE_VERSION, "10000",
185 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
186 AAIProperties.START_TX_ID, "JUNIT-C",
187 AAIProperties.END_SOT, "JUNIT-U-1",
188 AAIProperties.END_TX_ID, "JUNIT-U-1",
189 AAIProperties.START_TS, 10000L,
190 AAIProperties.END_TS, 13000L
192 .property(AAIProperties.RESOURCE_VERSION, "13000",
193 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-1",
194 AAIProperties.START_TX_ID, "JUNIT-U-1",
195 AAIProperties.END_SOT, "JUNIT-U-2",
196 AAIProperties.END_TX_ID, "JUNIT-U-2",
197 AAIProperties.START_TS, 13000L,
198 AAIProperties.END_TS, 15000L
200 .property(AAIProperties.RESOURCE_VERSION, "15000",
201 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-2",
202 AAIProperties.START_TX_ID, "JUNIT-U-2",
203 AAIProperties.END_SOT, "JUNIT-U-3",
204 AAIProperties.END_TX_ID, "JUNIT-U-3",
205 AAIProperties.START_TS, 15000L,
206 AAIProperties.END_TS, 17000L
208 .property(AAIProperties.RESOURCE_VERSION, "17000",
209 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-3",
210 AAIProperties.START_TX_ID, "JUNIT-U-3",
211 AAIProperties.END_SOT, "JUNIT-U-4",
212 AAIProperties.END_TX_ID, "JUNIT-U-4",
213 AAIProperties.START_TS, 17000L,
214 AAIProperties.END_TS, 20000L
216 .property(AAIProperties.RESOURCE_VERSION, "20000",
217 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-4",
218 AAIProperties.START_TX_ID, "JUNIT-U-4",
219 AAIProperties.START_TS, 20000L
221 .property("hostname", "test-pserver-dsl",
222 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
223 AAIProperties.START_TX_ID, "JUNIT-C",
224 AAIProperties.START_TS, 10000L
226 .property("in-maint", true,
227 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
228 AAIProperties.START_TX_ID, "JUNIT-C",
229 AAIProperties.START_TS, 10000L
231 .property("equip-type", "second-ps-type",
232 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
233 AAIProperties.START_TX_ID, "JUNIT-C",
234 AAIProperties.END_SOT, "JUNIT-U-1",
235 AAIProperties.END_TX_ID, "JUNIT-U-1",
236 AAIProperties.START_TS, 10000L,
237 AAIProperties.END_TS, 13000L
239 .property("equip-type", "second-ps-type-recreated",
240 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-2",
241 AAIProperties.START_TX_ID, "JUNIT-U-2",
242 AAIProperties.END_SOT, "JUNIT-U-3",
243 AAIProperties.END_TX_ID, "JUNIT-U-3",
244 AAIProperties.START_TS, 15000L,
245 AAIProperties.END_TS, 17000L
247 .property("equip-type", "second-ps-type-update",
248 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-3",
249 AAIProperties.START_TX_ID, "JUNIT-U-3",
250 AAIProperties.START_TS, 17000L,
251 AAIProperties.END_SOT, "JUNIT-U-4",
252 AAIProperties.END_TX_ID, "JUNIT-U-4",
253 AAIProperties.END_TS, 20000L
255 .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
256 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
257 AAIProperties.START_TX_ID, "JUNIT-C",
258 AAIProperties.START_TS, 10000L
260 .property(AAIProperties.START_TS, 10000L,
261 AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
262 AAIProperties.START_TX_ID, "JUNIT-C",
263 AAIProperties.START_TS, 10000L
266 } catch (Exception ex) {
270 transaction.commit();
272 transaction.rollback();
273 fail("Unable to setup the graph");
278 private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
279 return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
282 private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint, String additionalFilterInParen) throws Exception {
283 Map<String, String> dslQueryMap = new HashMap<>();
284 dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
285 String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
286 httpEntity = new HttpEntity(payload, headers);
287 ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
288 JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
289 LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
291 assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
292 assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
297 private void verifyEquipTypeValues(JsonArray results, String... expectedEquipTypes) {
298 List<String> expected = Arrays.asList(expectedEquipTypes);
299 final List<String> actualEquipType = new ArrayList<>();
300 for (JsonElement result : results) {
301 for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
302 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
303 if (property.getAsJsonObject().has("value") && !property.getAsJsonObject().get("value").isJsonNull()) {
304 actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
306 actualEquipType.add(null);
311 assertThat("Verify equip-type in lifecycle", actualEquipType, is(expected));
314 private void verifyEquipTypeSoTs(JsonArray results, String... expectedSTOs) {
315 List<String> expected = Arrays.asList(expectedSTOs);
316 final List<String> actualEquipType = new ArrayList<>();
317 for (JsonElement result : results) {
318 for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
319 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
320 if (property.getAsJsonObject().has("sot") && !property.getAsJsonObject().get("sot").isJsonNull()) {
321 actualEquipType.add(property.getAsJsonObject().get("sot").getAsString());
323 actualEquipType.add(null);
328 assertThat("Verify equip-type SoTs in lifecycle", actualEquipType, is(expected));
331 private void verifyEquipTypeTxId(JsonArray results, String... expectedSTOs) {
332 List<String> expected = Arrays.asList(expectedSTOs);
333 final List<String> actualEquipType = new ArrayList<>();
334 for (JsonElement result : results) {
335 for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
336 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
337 if (property.getAsJsonObject().has("tx-id") && !property.getAsJsonObject().get("tx-id").isJsonNull()) {
338 actualEquipType.add(property.getAsJsonObject().get("tx-id").getAsString());
340 actualEquipType.add(null);
345 assertThat("Verify equip-type tx-ids in lifecycle", actualEquipType, is(expected));
348 private void verifyEquipTypeTimestamps(JsonArray results, Long... expectedSTOs) {
349 List<Long> expected = Arrays.asList(expectedSTOs);
350 final List<Long> actualEquipType = new ArrayList<>();
351 for (JsonElement result : results) {
352 for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
353 if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
354 if (property.getAsJsonObject().has("timestamp") && !property.getAsJsonObject().get("timestamp").isJsonNull()) {
355 actualEquipType.add(property.getAsJsonObject().get("timestamp").getAsLong());
357 actualEquipType.add(null);
362 assertThat("Verify equip-type timestamps in lifecycle", actualEquipType, is(expected));
365 private void verifyNodeTimestamps(JsonArray results, Long... nodeTimestamps) {
366 List<Long> expected = Arrays.asList(nodeTimestamps);
367 final List<Long> actualEquipType = new ArrayList<>();
368 for (JsonElement result : results) {
369 result.getAsJsonObject().get("node-actions").getAsJsonArray().forEach(jsonElement ->
370 actualEquipType.add(jsonElement.getAsJsonObject().get("timestamp").getAsLong()));
372 assertThat("Verify node-changes timestamps in lifecycle", actualEquipType, is(expected));
375 private void verifyNodeSot(JsonArray results, String... nodeSots) {
376 List<String> expected = Arrays.asList(nodeSots);
377 final List<String> actualEquipType = new ArrayList<>();
378 for (JsonElement result : results) {
379 result.getAsJsonObject().get("node-actions").getAsJsonArray().forEach(jsonElement ->
380 actualEquipType.add(jsonElement.getAsJsonObject().get("sot").getAsString()));
382 assertThat("Verify node-changes sot in lifecycle", actualEquipType, is(expected));
387 public void lifecycleQueryNoStartOrEndTsTest() throws Exception {
389 String endpoint = "/aai/v14/dsl?format=lifecycle";
390 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
391 assertEquals("Result size", 1, results.size());
393 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
394 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
395 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
396 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
397 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
400 String equipType = "first-ps-type";
401 results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
402 assertEquals("Filter equip-type on " + equipType, 1, results.size());
403 verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
404 verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
405 verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
406 verifyEquipTypeTimestamps(results, 500L, 100L);
407 verifyNodeTimestamps(results, 1000L, 100L);
409 equipType = "second-ps-type-recreated";
410 results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
411 assertEquals("Filter equip-type on " + equipType, 1, results.size());
412 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
413 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
414 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
415 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
416 verifyNodeTimestamps(results, 10000L);
422 public void lifecycleQueryStartTsBeforeCreationTimeTest() throws Exception {
424 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50";
425 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
426 assertEquals("Result size", 1, results.size());
428 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
429 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
430 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
431 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
432 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
435 String equipType = "first-ps-type";
436 results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
437 assertEquals("Filter equip-type on " + equipType, 1, results.size());
438 verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
439 verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
440 verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
441 verifyEquipTypeTimestamps(results, 500L, 100L);
442 verifyNodeTimestamps(results, 1000L, 100L);
444 equipType = "second-ps-type-recreated";
445 results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
446 assertEquals("Filter equip-type on " + equipType, 1, results.size());
447 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
448 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
449 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
450 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
451 verifyNodeTimestamps(results, 10000L);
455 public void lifecycleQueryStartTsAtCreationTimeTest() throws Exception {
457 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=100";
458 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
459 assertEquals("Result size", 1, results.size());
461 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
462 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
463 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
464 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
465 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
469 public void lifecycleQueryStartTsAfterCreationTimeTest() throws Exception {
471 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=300";
472 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
473 assertEquals("Result size", 1, results.size());
475 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update");
476 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
477 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
478 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L);
479 verifyNodeTimestamps(results, 10000L, 1000L);
483 public void lifecycleQueryStartTsAtFirstUpdateTimeTest() throws Exception {
485 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=500";
486 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
487 assertEquals("Result size", 1, results.size());
489 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update");
490 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
491 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
492 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L);
493 verifyNodeTimestamps(results, 10000L, 1000L);
497 public void lifecycleQueryStartTsAfterFirstUpdateTimeTest() throws Exception {
499 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=700";
500 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
501 assertEquals("Result size", 1, results.size());
503 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
504 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
505 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
506 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
507 verifyNodeTimestamps(results, 10000L, 1000L);
511 public void lifecycleQueryStartTsAtFirstDeleteTimeTest() throws Exception {
513 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=1000";
514 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
515 assertEquals("Result size", 1, results.size());
517 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
518 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
519 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
520 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
521 verifyNodeTimestamps(results, 10000L, 1000L);
525 public void lifecycleQueryStartTsAfterFirstDeleteTimeTest() throws Exception {
527 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=5000";
528 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
529 assertEquals("Result size", 1, results.size());
531 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
532 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
533 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
534 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
535 verifyNodeTimestamps(results, 10000L);
539 public void lifecycleQueryStartTsAtSecondCreateTimeTest() throws Exception {
541 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=10000";
542 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
543 assertEquals("Result size", 1, results.size());
545 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
546 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
547 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
548 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
549 verifyNodeTimestamps(results, 10000L);
553 public void lifecycleQueryStartTsAfterSecondCreateTimeTest() throws Exception {
555 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=12000";
556 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
557 assertEquals("Result size", 1, results.size());
559 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null);
560 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
561 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
562 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L);
563 verifyNodeTimestamps(results);
567 public void lifecycleQueryStartTsAtEquipTypeFirstDeleteOnSecondPsTimeTest() throws Exception {
569 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=13000";
570 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
571 assertEquals("Result size", 1, results.size());
573 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null);
574 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
575 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
576 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L);
577 verifyNodeTimestamps(results);
581 public void lifecycleQueryStartTsAfterEquipTypeFirstDeleteOnSecondPsTimeTest() throws Exception {
583 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=14000";
584 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
585 assertEquals("Result size", 1, results.size());
587 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated");
588 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
589 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
590 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L);
591 verifyNodeTimestamps(results);
595 public void lifecycleQueryStartTsAtEquipTypeRecreateOnSecondPsTimeTest() throws Exception {
597 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=15000";
598 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
599 assertEquals("Result size", 1, results.size());
601 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated");
602 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
603 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
604 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L);
605 verifyNodeTimestamps(results);
609 public void lifecycleQueryStartTsAfterEquipTypeRecreateOnSecondPsTimeTest() throws Exception {
611 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=16000";
612 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
613 assertEquals("Result size", 1, results.size());
615 verifyEquipTypeValues(results, null, "second-ps-type-update");
616 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3");
617 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3");
618 verifyEquipTypeTimestamps(results, 20000L, 17000L);
619 verifyNodeTimestamps(results);
623 public void lifecycleQueryStartTsAtEquipTypeUpdateOnSecondPsTimeTest() throws Exception {
625 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=17000";
626 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
627 assertEquals("Result size", 1, results.size());
629 verifyEquipTypeValues(results, null, "second-ps-type-update");
630 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3");
631 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3");
632 verifyEquipTypeTimestamps(results, 20000L, 17000L);
633 verifyNodeTimestamps(results);
637 public void lifecycleQueryStartTsAfterEquipTypeUpdateOnSecondPsTimeTest() throws Exception {
639 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=19000";
640 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
641 assertEquals("Result size", 1, results.size());
643 verifyEquipTypeValues(results, new String[] {null});
644 verifyEquipTypeSoTs(results, "JUNIT-U-4");
645 verifyEquipTypeTxId(results, "JUNIT-U-4");
646 verifyEquipTypeTimestamps(results, 20000L);
647 verifyNodeTimestamps(results);
651 public void lifecycleQueryStartTsOnEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
653 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=20000";
654 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
655 assertEquals("Result size", 1, results.size());
657 verifyEquipTypeValues(results, new String[] {null});
658 verifyEquipTypeSoTs(results, "JUNIT-U-4");
659 verifyEquipTypeTxId(results, "JUNIT-U-4");
660 verifyEquipTypeTimestamps(results, 20000L);
661 verifyNodeTimestamps(results);
665 public void lifecycleQueryStartTsAfterEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
667 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=22000";
668 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
669 assertEquals("Result size", 0, results.size());
671 verifyEquipTypeValues(results);
672 verifyEquipTypeSoTs(results);
673 verifyEquipTypeTxId(results);
674 verifyEquipTypeTimestamps(results);
675 verifyNodeTimestamps(results);
679 public void lifecycleQueryStartTsBeforeCreationEndTimeAfterEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
681 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=22000";
682 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
683 assertEquals("Result size", 1, results.size());
685 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
686 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
687 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
688 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
689 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
693 public void lifecycleQueryStartTsBeforeCreationEndTimeAtEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
695 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=20000";
696 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
697 assertEquals("Result size", 1, results.size());
699 verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
700 verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
701 verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
702 verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
703 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
707 public void lifecycleQueryStartTsBeforeCreationEndTimeBeforeEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
709 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=19000";
710 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
711 assertEquals("Result size", 1, results.size());
713 verifyEquipTypeValues(results, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
714 verifyEquipTypeSoTs(results, "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
715 verifyEquipTypeTxId(results, "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
716 verifyEquipTypeTimestamps(results, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
717 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
721 public void lifecycleQueryStartTsBeforeCreationEndTimeBeforeSecondPsCreateTimeTest() throws Exception {
723 String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=9000";
724 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
725 assertEquals("Result size", 1, results.size());
727 verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
728 verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
729 verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
730 verifyEquipTypeTimestamps(results, 500L, 100L);
731 verifyNodeTimestamps(results, 1000L, 100L);
735 public void verifyNodeActionsWithNoTimeRangeTest() throws Exception {
737 String endpoint = "/aai/v14/dsl?format=lifecycle";
738 JsonArray results = getResultsForPserverLookupByHostname(endpoint);
739 assertEquals("Result size", 1, results.size());
740 verifyNodeTimestamps(results, 10000L, 1000L, 100L);
741 verifyNodeSot(results, "JUNIT-C", "JUNIT-D", "JUNIT-C");