1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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;
18 import java.math.BigInteger;
19 import java.util.ArrayList;
20 import java.util.List;
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;
30 import com.orbitz.consul.model.ConsulResponse;
31 import com.orbitz.consul.model.health.ImmutableNode;
33 public class WriteBufferHandlerTest {
35 public void testhandle() {
36 List<ServiceHealth> list = new ArrayList<ServiceHealth>();
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()
44 .node(ImmutableNode.builder().node("").address("").build())
47 list.add(serviceHealth0);
50 boolean knownLeader = true;
51 BigInteger index = BigInteger.valueOf(1);
52 ConsulResponse<List<ServiceHealth>> object = new ConsulResponse<List<ServiceHealth>>(
53 list, lastContact, knownLeader, index);
55 WriteBufferHandler<List<ServiceHealth>> handler = new WriteBufferHandler<List<ServiceHealth>>(
56 ServiceData.DataType.service);
58 handler.handle(object);