Divide the MSB source codes into two repos
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / consulextend / expose / WriteBufferHandlerTest.java
1 package org.onap.msb.apiroute.wrapper.consulextend.expose;
2
3 import java.math.BigInteger;
4 import java.util.ArrayList;
5 import java.util.List;
6
7 import org.junit.Test;
8 import org.onap.msb.apiroute.wrapper.consulextend.expose.WriteBufferHandler;
9 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ImmutableService;
10 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ImmutableServiceHealth;
11 import org.onap.msb.apiroute.wrapper.consulextend.model.health.Service;
12 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ServiceHealth;
13 import org.onap.msb.apiroute.wrapper.queue.ServiceData;
14
15 import com.orbitz.consul.model.ConsulResponse;
16 import com.orbitz.consul.model.health.ImmutableNode;
17
18 public class WriteBufferHandlerTest {
19         @Test
20         public void testhandle() {
21                 List<ServiceHealth> list = new ArrayList<ServiceHealth>();
22
23                 // modifyIndex 1
24                 Service service0 = ImmutableService.builder().id("huangleibo1").port(0)
25                                 .address("").service("huangleibo").addTags("").createIndex(1)
26                                 .modifyIndex(1).build();
27                 ServiceHealth serviceHealth0 = ImmutableServiceHealth.builder()
28                                 .service(service0)
29                                 .node(ImmutableNode.builder().node("").address("").build())
30                                 .build();
31
32                 list.add(serviceHealth0);
33
34                 long lastContact = 1;
35                 boolean knownLeader = true;
36                 BigInteger index = BigInteger.valueOf(1);
37                 ConsulResponse<List<ServiceHealth>> object = new ConsulResponse<List<ServiceHealth>>(
38                                 list, lastContact, knownLeader, index);
39
40                 WriteBufferHandler<List<ServiceHealth>> handler = new WriteBufferHandler<List<ServiceHealth>>(
41                                 ServiceData.DataType.service);
42
43                 handler.handle(object);
44
45         }
46 }