2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
21 package org.onap.so.adapters.requestdb.rest;
23 import static org.junit.Assert.assertEquals;
24 import java.util.ArrayList;
25 import java.util.List;
26 import javax.transaction.Transactional;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
31 import org.onap.so.db.request.beans.RequestProcessingData;
32 import org.onap.so.db.request.client.RequestsDbClient;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.boot.web.server.LocalServerPort;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.test.context.ActiveProfiles;
37 import org.springframework.test.context.junit4.SpringRunner;
39 @RunWith(SpringRunner.class)
40 @SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
41 @ActiveProfiles("test")
42 public class RequestProcessingDataRequestDbQueryTest {
44 private RequestsDbClient client;
50 public void setPort() {
51 client.removePortFromEndpoint();
52 client.setPortToEndpoint(Integer.toString(port));
57 public void RequestProcessingDataBySoRequestIdTest() {
58 String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018";
59 String tag = "pincFabricConfigRequest";
60 RequestProcessingData firstEntry = new RequestProcessingData();
61 RequestProcessingData secondEntry = new RequestProcessingData();
62 List<RequestProcessingData> expectedList = new ArrayList<>();
63 firstEntry.setSoRequestId(soRequestId);
64 firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
65 firstEntry.setName("configurationId");
66 firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2");
67 firstEntry.setTag(tag);
68 secondEntry.setSoRequestId(soRequestId);
69 secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
70 secondEntry.setName("requestAction");
71 secondEntry.setValue("assign");
72 secondEntry.setTag(tag);
73 expectedList.add(firstEntry);
74 expectedList.add(secondEntry);
76 List<RequestProcessingData> dataFound = client.getRequestProcessingDataBySoRequestId(soRequestId);
77 // bean comparison with shazam fails serialization: Forgot to register a type adapter?
78 assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId());
79 assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId());
80 assertEquals(dataFound.get(0).getName(), firstEntry.getName());
81 assertEquals(dataFound.get(0).getValue(), firstEntry.getValue());
82 assertEquals(dataFound.get(0).getTag(), firstEntry.getTag());
83 assertEquals(dataFound.get(1).getSoRequestId(), secondEntry.getSoRequestId());
84 assertEquals(dataFound.get(1).getGroupingId(), secondEntry.getGroupingId());
85 assertEquals(dataFound.get(1).getName(), secondEntry.getName());
86 assertEquals(dataFound.get(1).getValue(), secondEntry.getValue());
87 assertEquals(dataFound.get(1).getTag(), secondEntry.getTag());