42908bcacdcab09d18d5f8027bc29afca00fb4eb
[msb/apigateway.git] /
1 /*******************************************************************************
2  * Copyright 2016-2017 ZTE, Inc. and others.
3  * 
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 
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
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;
17
18 import org.junit.Assert;
19 import org.junit.Test;
20
21 public class ServiceTest {
22
23         @Test
24         public void testImmutableService() {
25                 ImmutableService service0 = ImmutableService.builder()
26                                 .id("huangleibo_id").port(0).address("").service("huangleibo")
27                                 .addTags("111", "222").createIndex(1).modifyIndex(1).build();
28                 Assert.assertEquals("huangleibo_id", service0.getId());
29                 Assert.assertEquals(1, service0.getCreateIndex());
30                 Assert.assertEquals(1, service0.getModifyIndex());
31
32                 ImmutableService service1 = service0.withId("huangleibo_id")
33                                 .withId("new_id").withService("huangleibo")
34                                 .withService("new_service").withTags("new_tags")
35                                 .withAddress("").withAddress("new_address").withPort(0)
36                                 .withPort(1).withCreateIndex(1).withCreateIndex(2)
37                                 .withModifyIndex(1).withModifyIndex(2);
38
39                 Assert.assertFalse(service0.equals(service1));
40
41                 System.out.println(service1.hashCode());
42
43                 ImmutableService service2 = ImmutableService.builder().from(service1)
44                                 .build();
45                 Assert.assertEquals("new_id", service2.getId());
46         }
47 }