2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.modelloader.service;
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;
30 import org.junit.Test;
33 * Tests for NotificationDataImpl class
36 public class TestArtifactInfoImpl {
39 public void testGettersAndSetters() {
40 ArtifactInfoImpl info = new ArtifactInfoImpl();
41 String artifactName = "testname";
43 info.setArtifactName(artifactName);
44 assertThat(info.getArtifactName(), is(equalTo(artifactName)));
46 String artifactType = "test-type";
47 info.setArtifactType(artifactType);
48 assertThat(info.getArtifactType(), is(equalTo(artifactType)));
50 String artifactVersion = "v1";
51 info.setArtifactVersion(artifactVersion);
52 assertThat(info.getArtifactVersion(), is(equalTo(artifactVersion)));
54 String artifactDescription = "test description";
55 info.setArtifactDescription(artifactDescription);
56 assertThat(info.getArtifactDescription(), is(equalTo(artifactDescription)));
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()));
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)));
74 ArtifactInfoImpl other = new ArtifactInfoImpl();
75 assertThat(info, is(equalTo(other)));
76 assertThat(info.hashCode(), is(equalTo(other.hashCode())));
79 other.setArtifactName("");
80 assertThat(info, is(not(equalTo(other))));
82 info.setArtifactName("1234");
83 assertThat(info, is(not(equalTo(other))));
85 other.setArtifactName("1234");
86 assertThat(info, is(equalTo(other)));
87 assertThat(info.hashCode(), is(equalTo(other.hashCode())));
90 other.setArtifactType("");
91 assertThat(info, is(not(equalTo(other))));
93 info.setArtifactType("type");
94 assertThat(info, is(not(equalTo(other))));
96 other.setArtifactType("type");
97 assertThat(info, is(equalTo(other)));
98 assertThat(info.hashCode(), is(equalTo(other.hashCode())));
100 // Artifact Description
101 other.setArtifactDescription("");
102 assertThat(info, is(not(equalTo(other))));
104 info.setArtifactDescription("type");
105 assertThat(info, is(not(equalTo(other))));
107 other.setArtifactDescription("type");
108 assertThat(info, is(equalTo(other)));
109 assertThat(info.hashCode(), is(equalTo(other.hashCode())));
112 other.setArtifactVersion("");
113 assertThat(info, is(not(equalTo(other))));
115 info.setArtifactVersion("v1");
116 assertThat(info, is(not(equalTo(other))));
118 other.setArtifactVersion("v1");
119 assertThat(info, is(equalTo(other)));
120 assertThat(info.hashCode(), is(equalTo(other.hashCode())));