2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.binding.util;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import org.junit.Test;
15 public class StringValueObjectFactoryTest {
18 public void createTest() throws Exception {
19 final StringValueObjectFactory<?> stringValueObjectFactory =
20 StringValueObjectFactory.create(TestClass.class, "testTemplate");
21 assertNotNull(stringValueObjectFactory);
22 assertEquals("testTemplate", stringValueObjectFactory.getTemplate().toString());
26 public void newInstanceTest() throws Exception {
27 final StringValueObjectFactory<?> instance = StringValueObjectFactory.create(TestClass.class, "testTemplate");
29 assertEquals("instanceTest", instance.newInstance("instanceTest").toString());
32 @Test(expected = IllegalArgumentException.class)
33 public void createTestNoConstructor() throws Exception {
34 StringValueObjectFactory.create(Object.class, "");
37 @Test(expected = IllegalArgumentException.class)
38 public void createTestNoField() throws Exception {
39 StringValueObjectFactory.create(String.class, "");
42 public static final class TestClass {
44 @SuppressWarnings("checkstyle:memberName")
45 private final String _value;
47 public TestClass(final TestClass parent) {
48 this._value = parent._value;
51 public TestClass(final String value) {
56 public String toString() {