81629c5a6c2e45db5118422ed324d4c91c0f13b6
[msb/apigateway.git] /
1 package org.onap.msb.apiroute.wrapper.consulextend.model.health;
2
3 import org.junit.Assert;
4 import org.junit.Test;
5
6 public class ServiceTest {
7
8         @Test
9         public void testImmutableService() {
10                 ImmutableService service0 = ImmutableService.builder()
11                                 .id("huangleibo_id").port(0).address("").service("huangleibo")
12                                 .addTags("111", "222").createIndex(1).modifyIndex(1).build();
13                 Assert.assertEquals("huangleibo_id", service0.getId());
14                 Assert.assertEquals(1, service0.getCreateIndex());
15                 Assert.assertEquals(1, service0.getModifyIndex());
16
17                 ImmutableService service1 = service0.withId("huangleibo_id")
18                                 .withId("new_id").withService("huangleibo")
19                                 .withService("new_service").withTags("new_tags")
20                                 .withAddress("").withAddress("new_address").withPort(0)
21                                 .withPort(1).withCreateIndex(1).withCreateIndex(2)
22                                 .withModifyIndex(1).withModifyIndex(2);
23
24                 Assert.assertFalse(service0.equals(service1));
25
26                 System.out.println(service1.hashCode());
27
28                 ImmutableService service2 = ImmutableService.builder().from(service1)
29                                 .build();
30                 Assert.assertEquals("new_id", service2.getId());
31         }
32 }