diff options
Diffstat (limited to 'src/test/java/org/onap/clamp/loop/ServiceTest.java')
-rw-r--r-- | src/test/java/org/onap/clamp/loop/ServiceTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/test/java/org/onap/clamp/loop/ServiceTest.java b/src/test/java/org/onap/clamp/loop/ServiceTest.java new file mode 100644 index 00000000..45de5385 --- /dev/null +++ b/src/test/java/org/onap/clamp/loop/ServiceTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.JsonObject; + +import org.junit.Test; +import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.loop.service.Service; + +public class ServiceTest { + + @Test + public void equalMethodTest() { + String serviceStr1 = "{\"name\": \"vLoadBalancerMS\", \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\"}"; + String serviceStr2 = "{\"name\": \"vLoadBalancerMS2\", \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\"}"; + String serviceStr3 = "{\"name\": \"vLoadBalancerMS\",\"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fc11\"}"; + String resourceStr = "{\"CP\": {}}"; + + Service service1 = new Service(JsonUtils.GSON.fromJson(serviceStr1, JsonObject.class), + JsonUtils.GSON.fromJson(resourceStr, JsonObject.class)); + + Service service2 = new Service(JsonUtils.GSON.fromJson(serviceStr2, JsonObject.class), null); + + Service service3 = new Service(JsonUtils.GSON.fromJson(serviceStr3, JsonObject.class), + JsonUtils.GSON.fromJson(resourceStr, JsonObject.class)); + + assertThat(service1.equals(service2)).isEqualTo(true); + assertThat(service1.equals(service3)).isEqualTo(false); + } + +} |