Divide the MSB source codes into two repos
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / consulextend / expose / CheckServiceDataEmptyAndAutoStopWatchFilterTest.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
8
9
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.onap.msb.apiroute.wrapper.consulextend.Consul;
13 import org.onap.msb.apiroute.wrapper.consulextend.expose.CheckServiceDataEmptyAndAutoStopWatchFilter;
14 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ImmutableService;
15 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ImmutableServiceHealth;
16 import org.onap.msb.apiroute.wrapper.consulextend.model.health.Service;
17 import org.onap.msb.apiroute.wrapper.consulextend.model.health.ServiceHealth;
18 import org.onap.msb.apiroute.wrapper.util.RouteUtil;
19
20 import com.orbitz.consul.model.ConsulResponse;
21 import com.orbitz.consul.model.health.ImmutableNode;
22
23 public class CheckServiceDataEmptyAndAutoStopWatchFilterTest {
24         @Test
25         public void testfilter()
26         {
27                 
28                 
29                 CheckServiceDataEmptyAndAutoStopWatchFilter filter = new CheckServiceDataEmptyAndAutoStopWatchFilter("huangleibo");
30                 
31                 
32                 List<ServiceHealth> list = new ArrayList<ServiceHealth>();
33                 
34                 //id:huangleibo1,name:huangleibo,modifyIndex:1,createindex:1
35                 Service service0 = ImmutableService.builder().id("huangleibo1").port(0).address("")
36                                 .service("huangleibo").addTags("").createIndex(1).modifyIndex(1).build();
37                 ServiceHealth serviceHealth0 = ImmutableServiceHealth.builder()
38                                 .service(service0)
39                                 .node(ImmutableNode.builder().node("").address("").build())
40                                 .build();
41                 
42                 list.add(serviceHealth0);
43                 ConsulResponse<List<ServiceHealth>> object = new ConsulResponse<List<ServiceHealth>>(list,1,true, BigInteger.valueOf(1));
44                 
45                 //have service,return true
46                 Assert.assertTrue(filter.filter(object));
47                 
48                 //empty [],return false
49                 list.clear();
50                 Assert.assertFalse(filter.filter(object));
51                 
52         }
53 }