ab35bb330e144956871b5c4a9fe4cbf1001a4733
[honeycomb.git] / v3po / v3po2vpp / src / test / java / io / fd / honeycomb / translate / v3po / vppstate / VersionCustomizerTest.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
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
17 package io.fd.honeycomb.translate.v3po.vppstate;
18
19 import static org.mockito.Matchers.any;
20 import static org.mockito.Mockito.verify;
21 import static org.mockito.Mockito.when;
22
23 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
24 import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
25 import io.fd.vpp.jvpp.core.dto.ShowVersion;
26 import io.fd.vpp.jvpp.core.dto.ShowVersionReply;
27 import io.fd.vpp.jvpp.dto.ControlPing;
28 import io.fd.vpp.jvpp.dto.ControlPingReply;
29 import org.junit.Test;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppStateBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.state.Version;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.state.VersionBuilder;
33 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34
35 public class VersionCustomizerTest extends ReaderCustomizerTest<Version, VersionBuilder> {
36
37     public VersionCustomizerTest() {
38         super(Version.class, VppStateBuilder.class);
39     }
40
41     @Override
42     protected ReaderCustomizer<Version, VersionBuilder> initCustomizer() {
43         return new VersionCustomizer(api);
44     }
45
46     @Test
47     public void testReadCurrentAttributes() throws Exception {
48         final ShowVersionReply reply = new ShowVersionReply();
49         reply.version = new byte[] {};
50         reply.program = new byte[] {};
51         reply.buildDate = new byte[] {};
52         reply.buildDirectory = new byte[] {};
53
54         when(api.showVersion(any(ShowVersion.class))).thenReturn(future(reply));
55         when(api.send(any(ControlPing.class))).thenReturn(future(new ControlPingReply()));
56         getCustomizer().readCurrentAttributes(InstanceIdentifier.create(Version.class), new VersionBuilder(), ctx);
57         verify(api).showVersion(any(ShowVersion.class));
58         verify(api).send(any(ControlPing.class));
59     }
60 }