2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.db.request;
23 import static org.junit.Assert.assertEquals;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.onap.so.TestApplication;
28 import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
29 import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.boot.test.context.SpringBootTest;
32 import org.springframework.data.domain.Example;
33 import org.springframework.data.domain.ExampleMatcher;
34 import org.springframework.test.context.ActiveProfiles;
35 import org.springframework.test.context.junit4.SpringRunner;
37 @RunWith(SpringRunner.class)
38 @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
39 @ActiveProfiles("test")
40 public class OperationalEnvServiceModelStatusTest {
43 private OperationalEnvServiceModelStatusRepository repository;
47 public void updateWithoutAllKeys() throws Exception {
49 OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus();
50 status.setRequestId("request-id-1");
51 status.setOperationalEnvId("oper-env-id-1");
52 status.setServiceModelVersionId("service-model-ver-id-1");
53 status.setRetryCount(0);
55 repository.saveAndFlush(status);
56 OperationalEnvServiceModelStatus status2 = repository.findOneByOperationalEnvIdAndServiceModelVersionId("oper-env-id-1", "service-model-ver-id-1");
57 status2.setRetryCount(1);
59 repository.saveAndFlush(status2);
61 OperationalEnvServiceModelStatus status3 = new OperationalEnvServiceModelStatus();
63 status3.setRequestId("request-id-2");
64 status3.setOperationalEnvId("oper-env-id-1");
65 status3.setServiceModelVersionId("service-model-ver-id-2");
66 status3.setRetryCount(2);
68 repository.saveAndFlush(status3);
70 OperationalEnvServiceModelStatus exampleObj = new OperationalEnvServiceModelStatus();
71 exampleObj.setOperationalEnvId("oper-env-id-1");
72 exampleObj.setServiceModelVersionId("service-model-ver-id-1");
73 ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("requestId");
74 OperationalEnvServiceModelStatus foundStatus = repository.findOne(Example.of(exampleObj,matcher));
75 if(foundStatus== null)
76 throw new Exception("No status found");
78 assertEquals(new Integer(1), foundStatus.getRetryCount());