Merge "Refactor, fix code formatting and add unittests"
[dcaegen2/platform.git] / mod2 / catalog-service / src / test / java / org / onap / dcaegen2 / platform / mod / web / service / deploymentartifact / SearchDeploymentArtifactsTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  org.onap.dcae
4  *  ================================================================================
5  *  Copyright (c) 2020 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
10  *
11  *       http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
22
23 import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
24 import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
25 import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
26 import org.junit.jupiter.api.BeforeEach;
27 import org.junit.jupiter.api.extension.ExtendWith;
28 import org.mockito.Mock;
29 import org.mockito.junit.jupiter.MockitoExtension;
30
31 @ExtendWith(MockitoExtension.class)
32 public class SearchDeploymentArtifactsTest {
33
34     private DeploymentArtifactServiceImpl service;
35
36     @Mock
37     private DeploymentArtifactGateway repository;
38
39     private DeploymentArtifact artifact_1;
40     private DeploymentArtifact artifact_2;
41     private DeploymentArtifact artifact_3;
42
43     @BeforeEach
44     void setUp() {
45         service = new DeploymentArtifactServiceImpl();
46         service.setDeploymentArtifactGateway(repository);
47
48         //given
49         artifact_1 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
50         artifact_1.getMsInstanceInfo().setRelease("2008");
51         artifact_2 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.DEV_COMPLETE);
52         artifact_2.getMsInstanceInfo().setRelease("2010");
53         artifact_3 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.DEV_COMPLETE);
54         artifact_3.getMsInstanceInfo().setRelease("2008");
55
56     }
57
58 //    @Test
59 //    void findArtifacts_filteredWithRelease() throws Exception {
60 //        List<DeploymentArtifact> artifacts = Arrays.asList(artifact_1, artifact_3);
61 //        when(repository.findByReleaseOrStatusOfMsInstance("2008", null)).thenReturn(artifacts);
62 //
63 //        //when
64 //        DeploymentArtifactSearch search = new DeploymentArtifactSearch();
65 //        DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
66 //        filter.setRelease("2008");
67 //        search.setFilter(filter);
68 //
69 //        List<DeploymentArtifact> result = core.searchDeploymentArtifacts(search);
70 //
71 //        //assert
72 //        assertThat(result.size()).isEqualTo(2);
73 //    }
74 //
75 //    @Test
76 //    void findArtifacts_filteredWithStatus() throws Exception{
77 //        List<DeploymentArtifact> artifacts = Arrays.asList(artifact_2, artifact_3);
78 //        when(repository.findByReleaseOrStatusOfMsInstance(null, DeploymentArtifactStatus.DEV_COMPLETE))
79 //                .thenReturn(artifacts);
80 //
81 //        DeploymentArtifactSearch search = new DeploymentArtifactSearch();
82 //        DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
83 //        filter.setStatus(DeploymentArtifactStatus.DEV_COMPLETE);
84 //        search.setFilter(filter);
85 //
86 //        List<DeploymentArtifact> result = core.searchDeploymentArtifacts(search);
87 //        assertThat(result.size()).isEqualTo(2);
88 //
89 //    }
90 }