1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16 package org.onap.msb.apiroute.wrapper.consulextend.model.health;
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.onap.msb.apiroute.wrapper.consulextend.model.health.Service;
22 import com.orbitz.consul.model.health.HealthCheck;
23 import com.orbitz.consul.model.health.ImmutableHealthCheck;
24 import com.orbitz.consul.model.health.ImmutableNode;
25 import com.orbitz.consul.model.health.Node;
27 public class ServiceHealthTest {
30 public void TestImmutableServiceHealth() {
31 Service service = ImmutableService.builder().id("").port(0).address("")
32 .service("huangleibo").addTags("").createIndex(1)
33 .modifyIndex(1).build();
34 Node node = ImmutableNode.builder().node("").address("").build();
36 HealthCheck healthCheck0 = ImmutableHealthCheck.builder().checkId("")
37 .name("").node("").notes("").output("").serviceId("")
38 .serviceName("").status("").build();
39 HealthCheck healthCheck1 = ImmutableHealthCheck.builder().checkId("")
40 .name("").node("").notes("").output("").serviceId("")
41 .serviceName("").status("").build();
42 HealthCheck healthCheck2 = ImmutableHealthCheck.builder().checkId("")
43 .name("").node("").notes("").output("").serviceId("")
44 .serviceName("").status("").build();
46 ImmutableServiceHealth serviceHealth0 = ImmutableServiceHealth
47 .builder().service(service).node(node).addChecks(healthCheck0)
48 .addChecks(healthCheck1, healthCheck2).build();
50 Assert.assertNotNull(serviceHealth0.getNode());
51 Assert.assertNotNull(serviceHealth0.getChecks());
52 /* ############################################################### */
54 ImmutableServiceHealth serviceHealth1 = serviceHealth0.withNode(node)
55 .withNode(ImmutableNode.builder().node("").address("").build())
56 .withService(service).withService(ImmutableService.builder().id("").port(0).address("")
57 .service("huangleibo1111").addTags("").createIndex(1)
58 .modifyIndex(1).build()).withChecks(healthCheck0);
60 Assert.assertFalse(serviceHealth1.equals(serviceHealth0));
61 System.out.println(serviceHealth1.hashCode());
63 /* ############################################################### */
65 ImmutableServiceHealth serviceHealth2 = ImmutableServiceHealth.builder().from(serviceHealth1).build();
66 Assert.assertTrue(serviceHealth1.equals(serviceHealth2));