2 * Copyright (c) 2016 Cisco and/or its affiliates.
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.
17 package io.fd.honeycomb.v3po.translate.v3po.util;
19 import java.util.Random;
20 import org.junit.Assert;
21 import org.junit.Test;
23 public class VppApiInvocationExceptionTest {
26 public void testInstantiation() {
27 final String apiMethodName = "methodName";
30 VppApiInvocationException e = new VppApiInvocationException(apiMethodName, ctxId, code);
31 Assert.assertEquals(apiMethodName, e.getMethodName());
32 Assert.assertEquals(ctxId, e.getCtxId());
33 Assert.assertEquals(code, e.getErrorCode());
34 Assert.assertTrue(e.getMessage().contains(apiMethodName));
35 Assert.assertTrue(e.getMessage().contains(String.valueOf(code)));
36 Assert.assertTrue(e.getMessage().contains(String.valueOf(ctxId)));
39 @Test(expected = IllegalArgumentException.class)
40 public void testInstantiationFailed() {
41 final int code = new Random().nextInt(Integer.MAX_VALUE);
42 VppApiInvocationException e = new VppApiInvocationException("apiMethodName", 1, code);