Add license header for java files
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / consulextend / expose / WriteBufferHandlerTest.java
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.expose;
17
18 import java.math.BigInteger;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.junit.Test;
23 import org.onap.msb.apiroute.wrapper.consulextend.expose.WriteBufferHandler;
24 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ImmutableService;
25 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ImmutableServiceHealth;
26 import org.onap.msb.apiroute.wrapper.consulextend.model.health.Service;
27 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ServiceHealth;
28 import org.onap.msb.apiroute.wrapper.queue.ServiceData;
29
30 import com.orbitz.consul.model.ConsulResponse;
31 import com.orbitz.consul.model.health.ImmutableNode;
32
33 public class WriteBufferHandlerTest {
34         @Test
35         public void testhandle() {
36                 List<ServiceHealth> list = new ArrayList<ServiceHealth>();
37
38                 // modifyIndex 1
39                 Service service0 = ImmutableService.builder().id("huangleibo1").port(0)
40                                 .address("").service("huangleibo").addTags("").createIndex(1)
41                                 .modifyIndex(1).build();
42                 ServiceHealth serviceHealth0 = ImmutableServiceHealth.builder()
43                                 .service(service0)
44                                 .node(ImmutableNode.builder().node("").address("").build())
45                                 .build();
46
47                 list.add(serviceHealth0);
48
49                 long lastContact = 1;
50                 boolean knownLeader = true;
51                 BigInteger index = BigInteger.valueOf(1);
52                 ConsulResponse<List<ServiceHealth>> object = new ConsulResponse<List<ServiceHealth>>(
53                                 list, lastContact, knownLeader, index);
54
55                 WriteBufferHandler<List<ServiceHealth>> handler = new WriteBufferHandler<List<ServiceHealth>>(
56                                 ServiceData.DataType.service);
57
58                 handler.handle(object);
59
60         }
61 }