Update babel dependency in model-loader
[aai/model-loader.git] / src / test / java / org / onap / aai / modelloader / service / TestArtifactInfoImpl.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 European Software Marketing Ltd.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.modelloader.service;
22
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.hamcrest.CoreMatchers.not;
26 import static org.hamcrest.CoreMatchers.nullValue;
27 import static org.hamcrest.MatcherAssert.assertThat;
28 import static org.hamcrest.Matchers.empty;
29
30 import org.junit.Test;
31
32 /**
33  * Tests for NotificationDataImpl class
34  *
35  */
36 public class TestArtifactInfoImpl {
37
38     @Test
39     public void testGettersAndSetters() {
40         ArtifactInfoImpl info = new ArtifactInfoImpl();
41         String artifactName = "testname";
42
43         info.setArtifactName(artifactName);
44         assertThat(info.getArtifactName(), is(equalTo(artifactName)));
45
46         String artifactType = "test-type";
47         info.setArtifactType(artifactType);
48         assertThat(info.getArtifactType(), is(equalTo(artifactType)));
49
50         String artifactVersion = "v1";
51         info.setArtifactVersion(artifactVersion);
52         assertThat(info.getArtifactVersion(), is(equalTo(artifactVersion)));
53
54         String artifactDescription = "test description";
55         info.setArtifactDescription(artifactDescription);
56         assertThat(info.getArtifactDescription(), is(equalTo(artifactDescription)));
57
58         assertThat(info.getArtifactChecksum(), is(nullValue()));
59         assertThat(info.getArtifactTimeout(), is(nullValue()));
60         assertThat(info.getArtifactURL(), is(nullValue()));
61         assertThat(info.getArtifactUUID(), is(nullValue()));
62         assertThat(info.getGeneratedArtifact(), is(nullValue()));
63         assertThat(info.getRelatedArtifacts(), is(empty()));
64     }
65
66
67     @Test
68     public void testEquality() {
69         ArtifactInfoImpl info = new ArtifactInfoImpl();
70         assertThat(info, is(not(equalTo(null))));
71         assertThat(info, is(not(equalTo("")))); // NOSONAR
72         assertThat(info, is(equalTo(info)));
73
74         ArtifactInfoImpl other = new ArtifactInfoImpl();
75         assertThat(info, is(equalTo(other)));
76         assertThat(info.hashCode(), is(equalTo(other.hashCode())));
77
78         // Artifact Name
79         other.setArtifactName("");
80         assertThat(info, is(not(equalTo(other))));
81
82         info.setArtifactName("1234");
83         assertThat(info, is(not(equalTo(other))));
84
85         other.setArtifactName("1234");
86         assertThat(info, is(equalTo(other)));
87         assertThat(info.hashCode(), is(equalTo(other.hashCode())));
88
89         // Artifact Type
90         other.setArtifactType("");
91         assertThat(info, is(not(equalTo(other))));
92
93         info.setArtifactType("type");
94         assertThat(info, is(not(equalTo(other))));
95
96         other.setArtifactType("type");
97         assertThat(info, is(equalTo(other)));
98         assertThat(info.hashCode(), is(equalTo(other.hashCode())));
99
100         // Artifact Description
101         other.setArtifactDescription("");
102         assertThat(info, is(not(equalTo(other))));
103
104         info.setArtifactDescription("type");
105         assertThat(info, is(not(equalTo(other))));
106
107         other.setArtifactDescription("type");
108         assertThat(info, is(equalTo(other)));
109         assertThat(info.hashCode(), is(equalTo(other.hashCode())));
110
111         // Artifact Version
112         other.setArtifactVersion("");
113         assertThat(info, is(not(equalTo(other))));
114
115         info.setArtifactVersion("v1");
116         assertThat(info, is(not(equalTo(other))));
117
118         other.setArtifactVersion("v1");
119         assertThat(info, is(equalTo(other)));
120         assertThat(info.hashCode(), is(equalTo(other.hashCode())));
121     }
122
123 }