This is the last holdout of JUnit4, migrate it.
Change-Id: Ib63ecc67c6d38d384552b10fb4948420533f3b86
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
*/
package org.opendaylight.yangtools.binding.generator;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Range;
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.Restrictions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.stmt.ValueRange;
-import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
import org.opendaylight.yangtools.yang.model.ri.type.DerivedTypes;
import org.opendaylight.yangtools.yang.model.ri.type.InvalidLengthConstraintException;
import org.opendaylight.yangtools.yang.model.ri.type.RestrictedTypes;
-import org.opendaylight.yangtools.yang.model.ri.type.StringTypeBuilder;
-public class BindingGeneratorUtilTest {
+@ExtendWith(MockitoExtension.class)
+class BindingGeneratorUtilTest {
private static final QName ROOT = QName.create("test", "root");
- @Test
- public void getRestrictionsTest() throws InvalidLengthConstraintException {
- final PatternConstraint constraint = mock(PatternConstraint.class);
+ @Mock
+ private PatternConstraint constraint;
+ @Mock
+ private ConstraintMetaDefinition constraintMeta;
- final StringTypeBuilder builder =
- RestrictedTypes.newStringBuilder(BaseTypes.stringType(), ROOT);
+ @Test
+ void getRestrictionsTest() throws InvalidLengthConstraintException {
+ final var builder = RestrictedTypes.newStringBuilder(BaseTypes.stringType(), ROOT);
builder.addPatternConstraint(constraint);
- builder.setLengthConstraint(mock(ConstraintMetaDefinition.class), List.of(ValueRange.of(1, 2)));
+ builder.setLengthConstraint(constraintMeta, List.of(ValueRange.of(1, 2)));
- Restrictions restrictions = BindingGeneratorUtil.getRestrictions(builder.build());
+ final var restrictions = BindingGeneratorUtil.getRestrictions(builder.build());
assertNotNull(restrictions);
assertEquals(Set.of(Range.closed(1, 2)),
assertEquals(1, restrictions.getPatternConstraints().size());
assertFalse(restrictions.isEmpty());
- assertThat(restrictions.getPatternConstraints(), contains(constraint));
+ assertThat(restrictions.getPatternConstraints()).contains(constraint);
}
@Test
- public void getEmptyRestrictionsTest() {
- final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(BaseTypes.stringType(), ROOT).build();
- final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+ void getEmptyRestrictionsTest() {
+ final var type = DerivedTypes.derivedTypeBuilder(BaseTypes.stringType(), ROOT).build();
+ final var restrictions = BindingGeneratorUtil.getRestrictions(type);
assertNotNull(restrictions);
assertTrue(restrictions.isEmpty());
}
@Test
- public void getDefaultIntegerRestrictionsTest() {
- final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(BaseTypes.int16Type(), ROOT).build();
- final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+ void getDefaultIntegerRestrictionsTest() {
+ final var type = DerivedTypes.derivedTypeBuilder(BaseTypes.int16Type(), ROOT).build();
+ final var restrictions = BindingGeneratorUtil.getRestrictions(type);
assertNotNull(restrictions);
assertFalse(restrictions.isEmpty());
- assertEquals(((Int16TypeDefinition) type.getBaseType()).getRangeConstraint(),
+ assertEquals(assertInstanceOf(Int16TypeDefinition.class, type.getBaseType()).getRangeConstraint(),
restrictions.getRangeConstraint());
assertEquals(Optional.empty(), restrictions.getLengthConstraint());
assertEquals(List.of(), restrictions.getPatternConstraints());
}
@Test
- public void getDefaultUnsignedIntegerRestrictionsTest() {
- final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(BaseTypes.uint16Type(), ROOT).build();
- final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+ void getDefaultUnsignedIntegerRestrictionsTest() {
+ final var type = DerivedTypes.derivedTypeBuilder(BaseTypes.uint16Type(), ROOT).build();
+ final var restrictions = BindingGeneratorUtil.getRestrictions(type);
assertNotNull(restrictions);
assertFalse(restrictions.isEmpty());
- assertEquals(((Uint16TypeDefinition) type.getBaseType()).getRangeConstraint(),
+ assertEquals(assertInstanceOf(Uint16TypeDefinition.class, type.getBaseType()).getRangeConstraint(),
restrictions.getRangeConstraint());
assertEquals(Optional.empty(), restrictions.getLengthConstraint());
assertEquals(List.of(), restrictions.getPatternConstraints());
}
@Test
- public void getDefaultDecimalRestrictionsTest() {
- final DecimalTypeDefinition base = BaseTypes.decimalTypeBuilder(ROOT).setFractionDigits(10).build();
- final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(base, ROOT).build();
+ void getDefaultDecimalRestrictionsTest() {
+ final var base = BaseTypes.decimalTypeBuilder(ROOT).setFractionDigits(10).build();
+ final var type = DerivedTypes.derivedTypeBuilder(base, ROOT).build();
- final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+ final var restrictions = BindingGeneratorUtil.getRestrictions(type);
assertNotNull(restrictions);
assertFalse(restrictions.isEmpty());
}
@Test
- public void unicodeCharReplaceTest() {
- String inputString = "abcu\\uuuuu\\uuua\\u\\\\uabc\\\\uuuu\\\\\\uuuu\\\\\\\\uuuu///uu/u/u/u/u/u/u";
+ void unicodeCharReplaceTest() {
+ final var inputString = "abcu\\uuuuu\\uuua\\u\\\\uabc\\\\uuuu\\\\\\uuuu\\\\\\\\uuuu///uu/u/u/u/u/u/u";
assertEquals("abcu\\\\uuuuu\\\\uuua\\\\u\\\\uabc\\\\uuuu\\\\uuuu\\\\uuuu///uu/u/u/u/u/u/u",
BindingGeneratorUtil.replaceAllIllegalChars(inputString));
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class ActionsTest {
+class ActionsTest {
@Test
- public void actionsTypeTest() {
+ void actionsTypeTest() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/actions.yang"));
assertNotNull(generateTypes);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.contract.Naming;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class AugmentRelativeXPathTest {
+class AugmentRelativeXPathTest {
@Test
- public void testAugmentationWithRelativeXPath() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+ void testAugmentationWithRelativeXPath() {
+ final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/augment-relative-xpath-models"));
- assertNotNull("genTypes is null", genTypes);
+ assertNotNull(genTypes);
assertEquals(27, genTypes.size());
GeneratedTransferObject gtInterfaceKey = null;
GeneratedType gtTunnel = null;
GeneratedTransferObject gtTunnelKey = null;
- for (final GeneratedType type : genTypes) {
+ for (var type : genTypes) {
if (!type.getPackageName().contains("augment._abstract.topology")) {
continue;
}
if (type.getName().equals("InterfaceKey")) {
- gtInterfaceKey = (GeneratedTransferObject) type;
+ gtInterfaceKey = assertInstanceOf(GeneratedTransferObject.class, type);
- final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
- assertNotNull("InterfaceKey properties are null", properties);
+ final var properties = gtInterfaceKey.getProperties();
+ assertNotNull(properties, "InterfaceKey properties are null");
assertEquals(1, properties.size());
- final GeneratedProperty property = properties.getFirst();
+ final var property = properties.getFirst();
assertEquals("interfaceId", property.getName());
- assertNotNull("interfaceId return type is null", property.getReturnType());
+ assertNotNull(property.getReturnType(), "interfaceId return type is null");
assertEquals(JavaTypeName.create(String.class), property.getReturnType().getIdentifier());
} else if (type.getName().equals("Interface")) {
gtInterface = type;
- final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
- assertNotNull("Interface methods are null", gtInterfaceMethods);
+ final var gtInterfaceMethods = gtInterface.getMethodDefinitions();
+ assertNotNull(gtInterfaceMethods, "Interface methods are null");
assertEquals(9, gtInterfaceMethods.size());
MethodSignature getIfcKeyMethod = null;
- for (final MethodSignature method : gtInterfaceMethods) {
+ for (var method : gtInterfaceMethods) {
if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
getIfcKeyMethod = method;
break;
}
}
- assertNotNull("getKey method is null", getIfcKeyMethod);
- assertNotNull("getKey method return type is null", getIfcKeyMethod.getReturnType());
+ assertNotNull(getIfcKeyMethod, "getKey method is null");
+ assertNotNull(getIfcKeyMethod.getReturnType(), "getKey method return type is null");
assertEquals(JavaTypeName.create(
"org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology.rev130503.topology.interfaces",
"InterfaceKey"),
} else if (type.getName().equals("Tunnel")) {
gtTunnel = type;
- final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
- assertNotNull("Tunnel methods are null", tunnelMethods);
+ final var tunnelMethods = gtTunnel.getMethodDefinitions();
+ assertNotNull(tunnelMethods, "Tunnel methods are null");
assertEquals(7, tunnelMethods.size());
MethodSignature getTunnelKeyMethod = null;
- for (MethodSignature method : tunnelMethods) {
+ for (var method : tunnelMethods) {
if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
getTunnelKeyMethod = method;
break;
}
}
- assertNotNull("getKey method is null", getTunnelKeyMethod);
- assertNotNull("getKey method return type", getTunnelKeyMethod.getReturnType());
+ assertNotNull(getTunnelKeyMethod, "getKey method is null");
+ assertNotNull(getTunnelKeyMethod.getReturnType(), "getKey method return type");
assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology"
+ ".rev130503.topology.network.links.network.link.tunnels", "TunnelKey"),
getTunnelKeyMethod.getReturnType().getIdentifier());
} else if (type.getName().equals("TunnelKey")) {
- assertThat(type, instanceOf(GeneratedTransferObject.class));
+ gtTunnelKey = assertInstanceOf(GeneratedTransferObject.class, type);
- gtTunnelKey = (GeneratedTransferObject) type;
-
- final List<GeneratedProperty> properties = gtTunnelKey.getProperties();
- assertNotNull("TunnelKey properties are null", properties);
+ final var properties = gtTunnelKey.getProperties();
+ assertNotNull(properties, "TunnelKey properties are null");
assertEquals(1, properties.size());
- final GeneratedProperty property = properties.getFirst();
+ final var property = properties.getFirst();
assertEquals("tunnelId", property.getName());
- assertNotNull("tunnelId return type is null", property.getReturnType());
+ assertNotNull(property.getReturnType(), "tunnelId return type is null");
assertEquals(
JavaTypeName.create("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208", "Uri"),
property.getReturnType().getIdentifier());
}
}
- assertNotNull("Interface is null", gtInterface);
- assertNotNull("InterfaceKey is null", gtInterfaceKey);
- assertNotNull("Tunnel is null", gtTunnel);
- assertNotNull("TunnelKey is null", gtTunnelKey);
+ assertNotNull(gtInterface, "Interface is null");
+ assertNotNull(gtInterfaceKey, "InterfaceKey is null");
+ assertNotNull(gtTunnel, "Tunnel is null");
+ assertNotNull(gtTunnelKey, "TunnelKey is null");
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.contract.Naming;
import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.binding.model.ri.Types;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class AugmentedTypeTest {
+class AugmentedTypeTest {
@Test
- public void augmentedAbstractTopologyTest() {
- final EffectiveModelContext context = YangParserTestUtils.parseYangResources(AugmentedTypeTest.class,
+ void augmentedAbstractTopologyTest() {
+ final var context = YangParserTestUtils.parseYangResources(AugmentedTypeTest.class,
"/augment-test-models/abstract-topology@2013-02-08.yang",
"/augment-test-models/augment-abstract-topology@2013-05-03.yang",
"/augment-test-models/augment-network-link-attributes@2013-05-03.yang",
"/augment-test-models/augment-topology-tunnels@2013-05-03.yang",
"/augment-test-models/ietf-interfaces@2012-11-15.yang");
- assertNotNull("Schema Context is null", context);
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(context);
+ final var genTypes = DefaultBindingGenerator.generateFor(context);
assertEquals(31, genTypes.size());
GeneratedTransferObject gtInterfaceKey = null;
GeneratedTransferObject gtTunnelKey = null;
GeneratedType gtNetworkLink2 = null;
- for (final GeneratedType type : genTypes) {
+ for (var type : genTypes) {
if (!type.getPackageName().contains("augment._abstract.topology")) {
continue;
}
if (type.getName().equals("InterfaceKey")) {
- gtInterfaceKey = (GeneratedTransferObject) type;
+ gtInterfaceKey = assertInstanceOf(GeneratedTransferObject.class, type);
} else if (type.getName().equals("Interface")) {
gtInterface = type;
} else if (type.getName().equals("Tunnel")) {
gtTunnel = type;
} else if (type.getName().equals("TunnelKey")) {
- gtTunnelKey = (GeneratedTransferObject) type;
+ gtTunnelKey = assertInstanceOf(GeneratedTransferObject.class, type);
} else if (type.getName().equals("NetworkLink2")) {
gtNetworkLink2 = type;
}
}
// 'Interface
- assertNotNull("gtInterface is null", gtInterface);
- final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
- assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
+ assertNotNull(gtInterface, "gtInterface is null");
+ final var gtInterfaceMethods = gtInterface.getMethodDefinitions();
+ assertNotNull(gtInterfaceMethods, "gtInterfaceMethods is null");
MethodSignature getIfcKeyMethod = null;
for (final MethodSignature method : gtInterfaceMethods) {
if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
break;
}
}
- assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);
- assertThat(getIfcKeyMethod.getReturnType(), instanceOf(GeneratedTransferObject.class));
+ assertNotNull(getIfcKeyMethod, "getIfcKeyMethod is null");
+ var retType = assertInstanceOf(GeneratedTransferObject.class, getIfcKeyMethod.getReturnType());
assertEquals(JavaTypeName.create(
"org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology.rev130503.topology.interfaces",
- "InterfaceKey"), getIfcKeyMethod.getReturnType().getIdentifier());
+ "InterfaceKey"), retType.getIdentifier());
MethodSignature getHigherLayerIfMethod = null;
- for (final MethodSignature method : gtInterfaceMethods) {
+ for (var method : gtInterfaceMethods) {
if (method.getName().equals("getHigherLayerIf")) {
getHigherLayerIfMethod = method;
break;
}
}
- assertNotNull("getHigherLayerIf method is null", getHigherLayerIfMethod);
+ assertNotNull(getHigherLayerIfMethod, "getHigherLayerIf method is null");
assertEquals(Types.setTypeFor(Types.STRING), getHigherLayerIfMethod.getReturnType());
// 'InterfaceKey'
- assertNotNull("InterfaceKey is null", gtInterfaceKey);
- final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
- assertNotNull("properties is null", properties);
+ assertNotNull(gtInterfaceKey, "InterfaceKey is null");
+ final var properties = gtInterfaceKey.getProperties();
+ assertNotNull(properties, "properties is null");
GeneratedProperty gtInterfaceId = null;
- for (final GeneratedProperty property : properties) {
+ for (var property : properties) {
if (property.getName().equals("interfaceId")) {
gtInterfaceId = property;
break;
}
}
- assertNotNull("interfaceId is null", gtInterfaceId);
+ assertNotNull(gtInterfaceId, "interfaceId is null");
assertEquals(Types.STRING, gtInterfaceId.getReturnType());
// 'Tunnel'
- assertNotNull("Tunnel is null", gtTunnel);
- final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
- assertNotNull("Tunnel methods are null", tunnelMethods);
+ assertNotNull(gtTunnel, "Tunnel is null");
+ final var tunnelMethods = gtTunnel.getMethodDefinitions();
+ assertNotNull(tunnelMethods, "Tunnel methods are null");
MethodSignature getTunnelKeyMethod = null;
- for (MethodSignature method : tunnelMethods) {
+ for (var method : tunnelMethods) {
if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
getTunnelKeyMethod = method;
break;
}
}
- assertNotNull("getKey method of Tunnel is null", getTunnelKeyMethod);
+ assertNotNull(getTunnelKeyMethod, "getKey method of Tunnel is null");
- var retType = getTunnelKeyMethod.getReturnType();
- assertThat(retType, instanceOf(GeneratedTransferObject.class));
+ retType = assertInstanceOf(GeneratedTransferObject.class, getTunnelKeyMethod.getReturnType());
assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology.rev130503"
+ ".topology.network.links.network.link.tunnels", "TunnelKey"), retType.getIdentifier());
// 'TunnelKey'
- assertNotNull("TunnelKey is null", gtTunnelKey);
- final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
- assertNotNull("TunnelKey properties are null", tunnelKeyProperties);
+ assertNotNull(gtTunnelKey, "TunnelKey is null");
+ final var tunnelKeyProperties = gtTunnelKey.getProperties();
+ assertNotNull(tunnelKeyProperties, "TunnelKey properties are null");
GeneratedProperty gtTunnelId = null;
- for (final GeneratedProperty property : tunnelKeyProperties) {
+ for (var property : tunnelKeyProperties) {
if (property.getName().equals("tunnelId")) {
gtTunnelId = property;
}
}
- assertNotNull("tunnelId is null", gtTunnelId);
+ assertNotNull(gtTunnelId, "tunnelId is null");
assertEquals(Types.typeForClass(Integer.class), gtTunnelId.getReturnType());
// 'NetworkLink2'
- assertNotNull("NetworkLink2 is null", gtNetworkLink2);
+ assertNotNull(gtNetworkLink2, "NetworkLink2 is null");
- final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
- assertNotNull("NetworkLink2 methods are null", networkLink2Methods);
+ final var networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
+ assertNotNull(networkLink2Methods, "NetworkLink2 methods are null");
MethodSignature getIfcMethod = null;
- for (MethodSignature method : networkLink2Methods) {
+ for (var method : networkLink2Methods) {
if (method.getName().equals("getInterface")) {
getIfcMethod = method;
break;
}
}
- assertNotNull("getInterface method is null", getIfcMethod);
+ assertNotNull(getIfcMethod, "getInterface method is null");
assertEquals(Types.STRING, getIfcMethod.getReturnType());
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class BinaryTypeTest {
+class BinaryTypeTest {
@Test
- public void binaryTypeTest() {
+ void binaryTypeTest() {
final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/binary-type-test-models"));
assertEquals(9, genTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.binding.model.api.Type;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class BindingGeneratorImplTest {
+class BindingGeneratorImplTest {
@Test
- public void isisTotpologyStatementParserTest() {
- List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
+ void isisTotpologyStatementParserTest() {
+ final var generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
BindingGeneratorImplTest.class,
"/isis-topology/network-topology@2013-10-21.yang", "/isis-topology/isis-topology@2013-10-21.yang",
"/isis-topology/l3-unicast-igp-topology@2013-10-21.yang"));
}
@Test
- public void choiceNodeGenerationTest() {
- List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void choiceNodeGenerationTest() {
+ final var generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/binding-generator-impl-test/choice-test.yang"));
GeneratedType choiceTestData = null;
GeneratedType myList2 = null;
GeneratedType myContainer2 = null;
- for (GeneratedType type : generateTypes) {
+ for (var type : generateTypes) {
switch (type.getName()) {
- case "ChoiceTestData":
- choiceTestData = type;
- break;
- case "Myrootcontainer":
- myRootContainer = type;
- break;
- case "Mylist":
- myList = type;
- break;
- case "Mylist2":
- myList2 = type;
- break;
- case "Mycontainer":
- myContainer = type;
- break;
- case "Mycontainer2":
- myContainer2 = type;
- break;
- default:
+ case "ChoiceTestData" -> choiceTestData = type;
+ case "Myrootcontainer" -> myRootContainer = type;
+ case "Mylist" -> myList = type;
+ case "Mylist2" -> myList2 = type;
+ case "Mycontainer" -> myContainer = type;
+ case "Mycontainer2" -> myContainer2 = type;
+ default -> {
// ignore
+ }
}
}
assertNotNull(myContainer2);
Type childOfParamType = null;
- for (Type type : myContainer.getImplements()) {
+ for (var type : myContainer.getImplements()) {
if (type.getName().equals("ChildOf")) {
- childOfParamType = ((ParameterizedType) type).getActualTypeArguments()[0];
+ childOfParamType = assertInstanceOf(ParameterizedType.class, type).getActualTypeArguments()[0];
break;
}
}
assertEquals("ChoiceTestData", childOfParamType.getName());
childOfParamType = null;
- for (Type type : myList.getImplements()) {
+ for (var type : myList.getImplements()) {
if (type.getName().equals("ChildOf")) {
- childOfParamType = ((ParameterizedType) type).getActualTypeArguments()[0];
+ childOfParamType = assertInstanceOf(ParameterizedType.class, type).getActualTypeArguments()[0];
break;
}
}
assertEquals("ChoiceTestData", childOfParamType.getName());
childOfParamType = null;
- for (Type type : myContainer2.getImplements()) {
+ for (var type : myContainer2.getImplements()) {
if (type.getName().equals("ChildOf")) {
- childOfParamType = ((ParameterizedType) type).getActualTypeArguments()[0];
+ childOfParamType = assertInstanceOf(ParameterizedType.class, type).getActualTypeArguments()[0];
break;
}
}
}
@Test
- public void notificationGenerationTest() {
- List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void notificationGenerationTest() {
+ final var generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/binding-generator-impl-test/notification-test.yang"));
GeneratedType foo = null;
- for (GeneratedType type : generateTypes) {
+ for (var type : generateTypes) {
if (type.getName().equals("Foo")) {
foo = type;
break;
}
}
+ assertNotNull(foo);
+
Type childOf = null;
Type dataObject = null;
- for (Type type : foo.getImplements()) {
+ for (var type : foo.getImplements()) {
switch (type.getName()) {
case "ChildOf":
childOf = type;
}
@Test
- public void testBaseYangTypes() {
+ void testBaseYangTypes() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/base-yang-types.yang"));
assertEquals(19, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsAttributes;
import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsMethods;
import java.util.List;
import java.util.stream.Collectors;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class BitAndUnionTOEnclosingTest {
-
+class BitAndUnionTOEnclosingTest {
private static List<GeneratedType> genTypes = null;
private static GeneratedType parentContainer = null;
- @BeforeClass
- public static void loadTestResources() {
+ @BeforeAll
+ static void loadTestResources() {
genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/bit_and_union.yang"));
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (genType.getName().equals("ParentContainer") && !(genType instanceof GeneratedTransferObject)) {
parentContainer = genType;
}
}
@Test
- public void testNestedTypesInLeaf() {
- final List<GeneratedType> enclosedTypes = parentContainer.getEnclosedTypes();
+ void testNestedTypesInLeaf() {
+ final var enclosedTypes = parentContainer.getEnclosedTypes();
assertEquals(3, enclosedTypes.size());
// nested types in leaf
- final List<GeneratedTransferObject> lfLeafs = enclosedTypes.stream()
+ final var lfLeafs = enclosedTypes.stream()
.filter(genType -> genType.getName().equals("Lf"))
- .map(genType -> {
- assertThat(genType, instanceOf(GeneratedTransferObject.class));
- return (GeneratedTransferObject) genType;
- })
+ .map(genType -> assertInstanceOf(GeneratedTransferObject.class, genType))
.collect(Collectors.toList());
- assertEquals("Lf TO has incorrect number of occurences.", 1, lfLeafs.size());
- GeneratedTransferObject lfLeaf = lfLeafs.get(0);
- assertEquals("Lf has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
- lfLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+ assertEquals(1, lfLeafs.size(), "Lf TO has incorrect number of occurences.");
+ final var lfLeaf = lfLeafs.getFirst();
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
+ lfLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+ "Lf has incorrect package name.");
- assertEquals("Lf generated TO has incorrect number of properties", 2, lfLeaf.getProperties().size());
+ assertEquals(2, lfLeaf.getProperties().size(), "Lf generated TO has incorrect number of properties");
containsAttributes(lfLeaf, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(lfLeaf, true, false, true, new NameTypePattern("lf$1", "Lf$1"));
// nested types in Lf
- final List<GeneratedType> lfTypes = lfLeaf.getEnclosedTypes();
+ final var lfTypes = lfLeaf.getEnclosedTypes();
assertEquals(1, lfTypes.size());
- final GeneratedType lf1Leaf = lfTypes.get(0);
+ final var lf1Leaf = lfTypes.getFirst();
assertEquals("Lf$1", lf1Leaf.getName());
- assertEquals("Lf$1 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf",
- lf1Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf",
+ lf1Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+ "Lf$1 has incorrect package name.");
- assertThat(lf1Leaf, instanceOf(GeneratedTransferObject.class));
- final GeneratedTransferObject lf1gto = (GeneratedTransferObject) lf1Leaf;
- assertEquals("Lf$1 generated TO has incorrect number of properties", 4, lf1Leaf.getProperties().size());
+ final var lf1gto = assertInstanceOf(GeneratedTransferObject.class, lf1Leaf);
+ assertEquals(4, lf1Leaf.getProperties().size(), "Lf$1 generated TO has incorrect number of properties");
containsAttributes(lf1gto, true, true, true, new NameTypePattern("uint32", "Uint32"));
containsAttributes(lf1gto, true, true, true, new NameTypePattern("int8", "Byte"));
containsAttributes(lf1gto, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(lf1gto, true, false, true, new NameTypePattern("lf$2", "Lf$2"));
// nested types in Lf1
- final List<GeneratedType> lf1Types = lf1Leaf.getEnclosedTypes();
+ final var lf1Types = lf1Leaf.getEnclosedTypes();
assertEquals(1, lf1Types.size());
- final GeneratedType lf2Leaf = lf1Types.get(0);
+ final var lf2Leaf = lf1Types.get(0);
assertEquals("Lf$2", lf2Leaf.getName());
- assertEquals("Lf$2 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf.Lf$1",
- lf2Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf.Lf$1",
+ lf2Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+ "Lf$2 has incorrect package name.");
- assertThat(lf2Leaf, instanceOf(GeneratedTransferObject.class));
- final GeneratedTransferObject lf2gto = (GeneratedTransferObject) lf2Leaf;
- assertEquals("Lf generated TO has incorrect number of properties", 2, lf2Leaf.getProperties().size());
+ final var lf2gto = assertInstanceOf(GeneratedTransferObject.class, lf2Leaf);
+ assertEquals(2, lf2Leaf.getProperties().size(), "Lf generated TO has incorrect number of properties");
containsAttributes(lf2gto, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(lf2gto, true, true, true, new NameTypePattern("uint64", "Uint64"));
}
@Test
- public void testNestedTypesInTypedef() {
-
+ void testNestedTypesInTypedef() {
GeneratedTransferObject typeUnionTypedef = null;
int typeUnionTypedefCounter = 0;
- for (GeneratedType genType : genTypes) {
- if (genType.getName().equals("TypeUnion") && genType instanceof GeneratedTransferObject) {
- typeUnionTypedef = (GeneratedTransferObject) genType;
+ for (var genType : genTypes) {
+ if (genType.getName().equals("TypeUnion") && genType instanceof GeneratedTransferObject gto) {
+ typeUnionTypedef = gto;
typeUnionTypedefCounter++;
}
}
- assertNotNull("TypeUnion TO wasn't found.", typeUnionTypedef);
- assertEquals("TypeUnion TO has incorrect number of occurences.", 1, typeUnionTypedefCounter);
+ assertNotNull(typeUnionTypedef, "TypeUnion TO wasn't found.");
+ assertEquals(1, typeUnionTypedefCounter, "TypeUnion TO has incorrect number of occurences.");
- assertNotNull("TypeUnion TO wasn't found.", typeUnionTypedef);
- assertEquals("TypeUnion TO has incorrect number of occurences.", 1, typeUnionTypedefCounter);
- assertEquals("TypeUnion has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnionTypedef.getPackageName());
+ assertNotNull(typeUnionTypedef, "TypeUnion TO wasn't found.");
+ assertEquals(1, typeUnionTypedefCounter, "TypeUnion TO has incorrect number of occurences.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnionTypedef.getPackageName(),
+ "TypeUnion has incorrect package name.");
- assertEquals("TypeUnion generated TO has incorrect number of properties", 2, typeUnionTypedef.getProperties()
- .size());
+ assertEquals(2, typeUnionTypedef.getProperties().size(),
+ "TypeUnion generated TO has incorrect number of properties");
containsAttributes(typeUnionTypedef, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(typeUnionTypedef, true, false, true, new NameTypePattern("typeUnion$1", "TypeUnion$1"));
- List<GeneratedType> nestedUnions = typeUnionTypedef.getEnclosedTypes();
- assertEquals("Incorrect number of nested unions", 1, nestedUnions.size());
+ final var nestedUnions = typeUnionTypedef.getEnclosedTypes();
+ assertEquals(1, nestedUnions.size(), "Incorrect number of nested unions");
- GeneratedType typeUnion1 = nestedUnions.get(0);
+ final var typeUnion1 = nestedUnions.getFirst();
assertEquals("TypeUnion$1", typeUnion1.getName());
- assertEquals("TypeUnion$1 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion1.getPackageName());
- assertEquals("TypeUnion1 generated TO has incorrect number of properties", 4,
- typeUnion1.getProperties().size());
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion1.getPackageName(),
+ "TypeUnion$1 has incorrect package name.");
+ assertEquals(4, typeUnion1.getProperties().size(),
+ "TypeUnion1 generated TO has incorrect number of properties");
- assertThat(typeUnion1, instanceOf(GeneratedTransferObject.class));
- GeneratedTransferObject typeUnion1gto = (GeneratedTransferObject) typeUnion1;
+ final var typeUnion1gto = assertInstanceOf(GeneratedTransferObject.class, typeUnion1);
containsAttributes(typeUnion1gto, true, true, true, new NameTypePattern("uint32", "Uint32"));
containsAttributes(typeUnion1gto, true, true, true, new NameTypePattern("int8", "Byte"));
containsAttributes(typeUnion1gto, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(typeUnion1gto, true, false, true, new NameTypePattern("typeUnion$2", "TypeUnion$2"));
- List<GeneratedType> nestedUnions1 = typeUnion1.getEnclosedTypes();
+ final var nestedUnions1 = typeUnion1.getEnclosedTypes();
assertEquals(1, nestedUnions1.size());
- GeneratedType typeUnion2 = nestedUnions1.get(0);
+ final var typeUnion2 = nestedUnions1.get(0);
assertEquals("TypeUnion$2", typeUnion2.getName());
- assertEquals("TypeUnion$2 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion2.getPackageName());
- assertEquals("TypeUnion2 generated TO has incorrect number of properties", 2,
- typeUnion2.getProperties().size());
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion2.getPackageName(),
+ "TypeUnion$2 has incorrect package name.");
+ assertEquals(2, typeUnion2.getProperties().size(),
+ "TypeUnion2 generated TO has incorrect number of properties");
- assertThat(typeUnion2, instanceOf(GeneratedTransferObject.class));
- GeneratedTransferObject typeUnion2gto = (GeneratedTransferObject) typeUnion2;
+ final var typeUnion2gto = assertInstanceOf(GeneratedTransferObject.class, typeUnion2);
containsAttributes(typeUnion2gto, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(typeUnion2gto, true, true, true, new NameTypePattern("uint64", "Uint64"));
}
@Test
public void bitAndUnionEnclosingTest() {
-
- assertNotNull("Parent container object wasn't found.", parentContainer);
+ assertNotNull(parentContainer, "Parent container object wasn't found.");
containsMethods(parentContainer, new NameTypePattern("getLf", "Lf"));
GeneratedTransferObject bitLeaf = null;
GeneratedTransferObject unionLeaf = null;
- List<GeneratedType> enclosedTypes = parentContainer.getEnclosedTypes();
- for (GeneratedType genType : enclosedTypes) {
- if (genType instanceof GeneratedTransferObject) {
- if (genType.getName().equals("BitLeaf")) {
- bitLeaf = (GeneratedTransferObject) genType;
- } else if (genType.getName().equals("UnionLeaf")) {
- unionLeaf = (GeneratedTransferObject) genType;
+ for (var genType : parentContainer.getEnclosedTypes()) {
+ if (genType instanceof GeneratedTransferObject gto) {
+ if (gto.getName().equals("BitLeaf")) {
+ bitLeaf = gto;
+ } else if (gto.getName().equals("UnionLeaf")) {
+ unionLeaf = gto;
}
}
}
- assertNotNull("BitLeaf TO wasn't found.", bitLeaf);
- assertNotNull("UnionLeaf TO wasn't found.", unionLeaf);
+ assertNotNull(bitLeaf, "BitLeaf TO wasn't found.");
+ assertNotNull(unionLeaf, "UnionLeaf TO wasn't found.");
- assertEquals("BitLeaf has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
- bitLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
- assertEquals("UnionLeaf has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
- unionLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
+ bitLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+ "BitLeaf has incorrect package name.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
+ unionLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+ "UnionLeaf has incorrect package name.");
- List<GeneratedProperty> propertiesBitLeaf = bitLeaf.getProperties();
GeneratedProperty firstBitProperty = null;
GeneratedProperty secondBitProperty = null;
GeneratedProperty thirdBitProperty = null;
-
- for (GeneratedProperty genProperty : propertiesBitLeaf) {
+ for (var genProperty : bitLeaf.getProperties()) {
if (genProperty.getName().equals("firstBit")) {
firstBitProperty = genProperty;
} else if (genProperty.getName().equals("secondBit")) {
}
}
- assertNotNull("firstBit property wasn't found", firstBitProperty);
- assertNotNull("secondBit property wasn't found", secondBitProperty);
- assertNotNull("thirdBit property wasn't found", thirdBitProperty);
-
- assertEquals("firstBit property has incorrect type", "boolean", firstBitProperty.getReturnType().getName());
- assertEquals("secondBit property has incorrect type", "boolean", secondBitProperty.getReturnType().getName());
- assertEquals("thirdBit property has incorrect type", "boolean", thirdBitProperty.getReturnType().getName());
+ assertNotNull(firstBitProperty, "firstBit property wasn't found");
+ assertEquals("boolean", firstBitProperty.getReturnType().getName(), "firstBit property has incorrect type");
+ assertNotNull(secondBitProperty, "secondBit property wasn't found");
+ assertEquals("boolean", secondBitProperty.getReturnType().getName(), "secondBit property has incorrect type");
+ assertNotNull(thirdBitProperty, "thirdBit property wasn't found");
+ assertEquals("boolean", thirdBitProperty.getReturnType().getName(), "thirdBit property has incorrect type");
GeneratedProperty uint32Property = null;
GeneratedProperty stringProperty = null;
GeneratedProperty uint8Property = null;
- List<GeneratedProperty> propertiesUnionLeaf = unionLeaf.getProperties();
- for (GeneratedProperty genProperty : propertiesUnionLeaf) {
+ for (var genProperty : unionLeaf.getProperties()) {
if (genProperty.getName().equals("int32")) {
uint32Property = genProperty;
} else if (genProperty.getName().equals("string")) {
}
}
- assertNotNull("uint32 property wasn't found", uint32Property);
- assertNotNull("string property wasn't found", stringProperty);
- assertNotNull("uint8 property wasn't found", uint8Property);
-
- assertEquals("uint32 property has incorrect type", "Integer", uint32Property.getReturnType().getName());
- assertEquals("string property has incorrect type", "String", stringProperty.getReturnType().getName());
- assertEquals("uint8 property has incorrect type", "Uint8", uint8Property.getReturnType().getName());
-
+ assertNotNull(uint32Property, "uint32 property wasn't found");
+ assertEquals("Integer", uint32Property.getReturnType().getName(), "uint32 property has incorrect type");
+ assertNotNull(stringProperty, "string property wasn't found");
+ assertEquals("String", stringProperty.getReturnType().getName(), "string property has incorrect type");
+ assertNotNull(uint8Property, "uint8 property wasn't found");
+ assertEquals("Uint8", uint8Property.getReturnType().getName(), "uint8 property has incorrect type");
}
-
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Bug4145Test {
+class Bug4145Test {
@Test
- public void bug4145Test() {
+ void bug4145Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/bug4145.yang"));
assertEquals(8, generateTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Bug6135Test {
+class Bug6135Test {
@Test
- public void bug6135Test() {
+ void bug6135Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/bug6135.yang"));
assertEquals(5, generateTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsInterface;
import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsMethods;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class ChoiceCaseGenTypesTest {
+class ChoiceCaseGenTypesTest {
@Test
- public void choiceCaseResolvingTypeTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+ void choiceCaseResolvingTypeTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/choice-case-type-test-models"));
- assertNotNull("genTypes is null", genTypes);
+ assertNotNull(genTypes, "genTypes is null");
assertEquals(41, genTypes.size());
// test for file choice-monitoring
- String pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701."
+ var pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701."
+ "netconf.state.datastores.datastore.locks";
GeneratedType genType = null;
- checkGeneratedType(genTypes, "LockType", pcgPref); // choice
+ // choice
+ checkGeneratedType(genTypes, "LockType", pcgPref);
- genType = checkGeneratedType(genTypes, "GlobalLock", pcgPref + ".lock.type"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "GlobalLock", pcgPref + ".lock.type");
SupportTestUtil.containsMethods(genType, new NameTypePattern("getGlobalLock", "GlobalLock"));
containsInterface("LockType", genType);
- genType = checkGeneratedType(genTypes, "PartialLock", pcgPref + ".lock.type"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "PartialLock", pcgPref + ".lock.type");
containsMethods(genType, new NameTypePattern("getPartialLock", "Map<PartialLockKey,PartialLock>"));
containsInterface("LockType", genType);
- genType = checkGeneratedType(genTypes, "Fingerprint", pcgPref + ".lock.type"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Fingerprint", pcgPref + ".lock.type");
containsMethods(genType, new NameTypePattern("getAlgorithmAndHash", "AlgorithmAndHash"));
containsInterface("LockType", genType);
- genType = checkGeneratedType(genTypes, "AlgorithmAndHash", pcgPref + ".lock.type.fingerprint"); // choice
+ // choice
+ genType = checkGeneratedType(genTypes, "AlgorithmAndHash", pcgPref + ".lock.type.fingerprint");
- genType = checkGeneratedType(genTypes, "Md5", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Md5", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
containsMethods(genType, new NameTypePattern("getMd5", "TlsFingerprintType"));
containsInterface("AlgorithmAndHash", genType);
- genType = checkGeneratedType(genTypes, "Sha1", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Sha1", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
containsMethods(genType, new NameTypePattern("getSha1", "TlsFingerprintType"));
containsInterface("AlgorithmAndHash", genType);
- genType = checkGeneratedType(genTypes, "Sha224", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Sha224", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
containsMethods(genType, new NameTypePattern("getSha224", "TlsFingerprintType"));
containsInterface("AlgorithmAndHash", genType);
- genType = checkGeneratedType(genTypes, "Sha256", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Sha256", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
containsMethods(genType, new NameTypePattern("getSha256", "TlsFingerprintType"));
containsInterface("AlgorithmAndHash", genType);
- genType = checkGeneratedType(genTypes, "Sha384", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Sha384", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
containsMethods(genType, new NameTypePattern("getSha384", "TlsFingerprintType"));
containsInterface("AlgorithmAndHash", genType);
- genType = checkGeneratedType(genTypes, "Sha512", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Sha512", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
containsMethods(genType, new NameTypePattern("getSha512", "TlsFingerprintType"));
containsInterface("AlgorithmAndHash", genType);
// "/nm:netconf-state/nm:datastores/nm:datastore/nm:locks/nm:lock-type"
pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.augment.monitoring.rev130701";
+ // choice
genType = checkGeneratedType(genTypes, "AutonomousLock", pcgPref
- + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
+ + ".netconf.state.datastores.datastore.locks.lock.type");
containsMethods(genType, new NameTypePattern("getAutonomousDef", "AutonomousDef"));
containsInterface("LockType", genType);
+ // choice
genType = checkGeneratedType(genTypes, "AnonymousLock", pcgPref
- + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
+ + ".netconf.state.datastores.datastore.locks.lock.type");
containsMethods(genType, new NameTypePattern("getLockTime", "Uint32"));
containsInterface("LockType", genType);
+ // choice
genType = checkGeneratedType(genTypes, "LeafAugCase", pcgPref
- + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
+ + ".netconf.state.datastores.datastore.locks.lock.type");
containsMethods(genType, new NameTypePattern("getLeafAugCase", "String"));
containsInterface("LockType", genType);
// augment
// "/nm:netconf-state/nm:datastores/nm:datastore/nm:locks/nm:lock-type/nm:partial-lock"
// {
- genType = checkGeneratedType(genTypes, "PartialLock1", pcgPref); // case
+ // case
+ genType = checkGeneratedType(genTypes, "PartialLock1", pcgPref);
containsMethods(genType, new NameTypePattern("getAugCaseByChoice", "AugCaseByChoice"));
containsInterface("Augmentation<PartialLock>", genType);
+ // choice
genType = checkGeneratedType(genTypes, "AugCaseByChoice", pcgPref
- + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock"); // choice
+ + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock");
+ // case
genType = checkGeneratedType(genTypes, "Foo", pcgPref
- + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice"); // case
+ + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice");
containsMethods(genType, new NameTypePattern("getFoo", "String"));
containsInterface("AugCaseByChoice", genType);
+ // case
genType = checkGeneratedType(genTypes, "Bar", pcgPref
- + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice"); // case
+ + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice");
containsMethods(genType, new NameTypePattern("getBar", "Boolean"));
containsInterface("AugCaseByChoice", genType);
// choice
genType = checkGeneratedType(genTypes, "StorageFormat", pcgPref + ".netconf.state.datastores.datastore");
+ // case
genType = checkGeneratedType(genTypes, "UnknownFiles", pcgPref
- + ".netconf.state.datastores.datastore.storage.format"); // case
+ + ".netconf.state.datastores.datastore.storage.format");
containsMethods(genType, new NameTypePattern("getFiles", "Map<FilesKey,Files>"));
containsInterface("StorageFormat", genType);
final String packageName, final int occurences) {
GeneratedType searchedGenType = null;
int searchedGenTypeCounter = 0;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals(genTypeName) && genType.getPackageName().equals(packageName)) {
searchedGenType = genType;
}
}
}
- assertNotNull("Generated type " + genTypeName + " wasn't found", searchedGenType);
- assertEquals(genTypeName + " generated type has incorrect number of occurences.", occurences,
- searchedGenTypeCounter);
+ assertNotNull(searchedGenType, "Generated type " + genTypeName + " wasn't found");
+ assertEquals(occurences, searchedGenTypeCounter,
+ genTypeName + " generated type has incorrect number of occurences.");
return searchedGenType;
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class ControllerTest {
+class ControllerTest {
@Test
- public void controllerAugmentationTest() {
+ void controllerAugmentationTest() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
ControllerTest.class,
"/controller-models/controller-network.yang", "/controller-models/controller-openflow.yang",
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import java.util.List;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.ri.BaseYangTypes;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class ExtendedTypedefTest {
+class ExtendedTypedefTest {
@Test
- public void constantGenerationTest() {
+ void constantGenerationTest() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
ExtendedTypedefTest.class, "/typedef_of_typedef.yang", "/ietf-models/ietf-inet-types.yang"));
GeneratedTransferObject extendedTypedefUnion = null;
GeneratedTransferObject unionTypedef = null;
GeneratedTransferObject typedefFromImport = null;
- for (final GeneratedType type : genTypes) {
- if (type instanceof GeneratedTransferObject) {
+ for (var type : genTypes) {
+ if (type instanceof GeneratedTransferObject gto) {
if (type.getName().equals("SimpleTypedef4")) {
- simpleTypedef4 = (GeneratedTransferObject) type;
+ simpleTypedef4 = gto;
} else if (type.getName().equals("ExtendedTypedefUnion")) {
- extendedTypedefUnion = (GeneratedTransferObject) type;
+ extendedTypedefUnion = gto;
} else if (type.getName().equals("UnionTypedef")) {
- unionTypedef = (GeneratedTransferObject) type;
+ unionTypedef = gto;
} else if (type.getName().equals("TypedefFromImport")) {
- typedefFromImport = (GeneratedTransferObject) type;
+ typedefFromImport = gto;
}
}
}
// typedef-from-import
- assertNotNull("TypedefFromImport not found", typedefFromImport);
- var properties = typedefFromImport.getProperties();
- assertEquals("Properties of TypedefFromImport should be empty", 0, properties.size());
- assertEquals("TypedefFromImport should be extended", "Ipv4Address", typedefFromImport.getSuperType().getName());
+ assertNotNull(typedefFromImport, "TypedefFromImport not found");
+ assertEquals(List.of(), typedefFromImport.getProperties(), "Properties of TypedefFromImport should be empty");
+ assertEquals("Ipv4Address", typedefFromImport.getSuperType().getName(), "TypedefFromImport should be extended");
// simple-typedef4
- assertNotNull("SimpleTypedef4 not found", simpleTypedef4);
- assertNotNull("ExtendedTypedefUnion not found", extendedTypedefUnion);
- assertNotNull("UnionTypedef", unionTypedef);
+ assertNotNull(simpleTypedef4, "SimpleTypedef4 not found");
+ assertNotNull(extendedTypedefUnion, "ExtendedTypedefUnion not found");
+ assertNotNull(unionTypedef, "UnionTypedef");
- properties = simpleTypedef4.getProperties();
- assertEquals("SimpleTypedef4 shouldn't have properties.", 0, properties.size());
+ assertEquals(List.of(), simpleTypedef4.getProperties(), "SimpleTypedef4 shouldn't have properties.");
- GeneratedTransferObject extendTO = simpleTypedef4.getSuperType();
- assertNotNull("SimpleTypedef4 should have extend.", extendTO);
- assertEquals("Incorrect extension for SimpleTypedef4.", "SimpleTypedef3", extendTO.getName());
- properties = extendTO.getProperties();
- assertEquals("SimpleTypedef3 shouldn't have properties.", 0, properties.size());
+ var extendTO = simpleTypedef4.getSuperType();
+ assertNotNull(extendTO, "SimpleTypedef4 should have extend.");
+ assertEquals("SimpleTypedef3", extendTO.getName(), "Incorrect extension for SimpleTypedef4.");
+ assertEquals(List.of(), extendTO.getProperties(), "SimpleTypedef3 shouldn't have properties.");
extendTO = extendTO.getSuperType();
- assertNotNull("SimpleTypedef3 should have extend.", extendTO);
- assertEquals("Incorrect extension for SimpleTypedef3.", "SimpleTypedef2", extendTO.getName());
- properties = extendTO.getProperties();
- assertEquals("SimpleTypedef2 shouldn't have properties.", 0, properties.size());
+ assertNotNull(extendTO, "SimpleTypedef3 should have extend.");
+ assertEquals("SimpleTypedef2", extendTO.getName(), "Incorrect extension for SimpleTypedef3.");
+ assertEquals(List.of(), extendTO.getProperties(), "SimpleTypedef2 shouldn't have properties.");
extendTO = extendTO.getSuperType();
- assertNotNull("SimpleTypedef2 should have extend.", extendTO);
- assertEquals("SimpleTypedef2 should be extended with SimpleTypedef1.", "SimpleTypedef1", extendTO.getName());
- properties = extendTO.getProperties();
- assertEquals("Incorrect number of properties in class SimpleTypedef1.", 1, properties.size());
+ assertNotNull(extendTO, "SimpleTypedef2 should have extend.");
+ assertEquals("SimpleTypedef1", extendTO.getName(), "SimpleTypedef2 should be extended with SimpleTypedef1.");
+ var properties = extendTO.getProperties();
+ assertEquals(1, properties.size(), "Incorrect number of properties in class SimpleTypedef1.");
- assertEquals("Incorrect property's name", "value", properties.get(0).getName());
- assertEquals("Property's incorrect type", BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType());
+ assertEquals("value", properties.getFirst().getName(), "Incorrect property's name");
+ assertEquals(BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType(), "Property's incorrect type");
extendTO = extendTO.getSuperType();
- assertNull("SimpleTypedef1 shouldn't have extend.", extendTO);
+ assertNull(extendTO, "SimpleTypedef1 shouldn't have extend.");
// extended-typedef-union
- assertNotNull("ExtendedTypedefUnion object not found", extendedTypedefUnion);
- properties = extendedTypedefUnion.getProperties();
- assertEquals("ExtendedTypedefUnion shouldn't have any property", 0, properties.size());
+ assertNotNull(extendedTypedefUnion, "ExtendedTypedefUnion object not found");
+ assertEquals(List.of(), extendedTypedefUnion.getProperties(),
+ "ExtendedTypedefUnion shouldn't have any property");
extendTO = extendedTypedefUnion.getSuperType();
- assertEquals("Incorrect extension fo ExtendedTypedefUnion.", "UnionTypedef", extendTO.getName());
- assertNull("UnionTypedef shouldn't be extended", extendTO.getSuperType());
+ assertEquals("UnionTypedef", extendTO.getName(), "Incorrect extension fo ExtendedTypedefUnion.");
+ assertNull(extendTO.getSuperType(), "UnionTypedef shouldn't be extended");
properties = extendTO.getProperties();
- assertEquals("Incorrect number of properties for UnionTypedef.", 4, properties.size());
+ assertEquals(4, properties.size(), "Incorrect number of properties for UnionTypedef.");
GeneratedProperty simpleTypedef4Property = null;
GeneratedProperty simpleTypedef1Property = null;
GeneratedProperty byteTypeProperty = null;
GeneratedProperty typedefEnumFruitProperty = null;
- for (GeneratedProperty genProperty : properties) {
+ for (var genProperty : properties) {
if (genProperty.getName().equals("simpleTypedef1")) {
simpleTypedef1Property = genProperty;
} else if (genProperty.getName().equals("simpleTypedef4")) {
}
}
- assertNotNull("simpleTypedef4 property not found in UnionTypedef", simpleTypedef4Property);
- assertNotNull("simpleTypedef1 property not found in UnionTypedef", simpleTypedef1Property);
- assertNotNull("byteType property not found in UnionTypedef", byteTypeProperty);
- assertNotNull("typedefEnumFruit property not found in UnionTypedef", typedefEnumFruitProperty);
-
- assertEquals("Incorrect type for property simpleTypedef4.", "SimpleTypedef4", simpleTypedef4Property
- .getReturnType().getName());
- assertEquals("Incorrect type for property simpleTypedef1.", "SimpleTypedef1", simpleTypedef1Property
- .getReturnType().getName());
- assertEquals("Incorrect type for property byteType.", "ByteType", byteTypeProperty.getReturnType().getName());
- assertEquals("Incorrect type for property typedefEnumFruit.", "TypedefEnumFruit", typedefEnumFruitProperty
- .getReturnType().getName());
+ assertNotNull(simpleTypedef4Property, "simpleTypedef4 property not found in UnionTypedef");
+ assertNotNull(simpleTypedef1Property, "simpleTypedef1 property not found in UnionTypedef");
+ assertNotNull(byteTypeProperty, "byteType property not found in UnionTypedef");
+ assertNotNull(typedefEnumFruitProperty, "typedefEnumFruit property not found in UnionTypedef");
+
+ assertEquals("SimpleTypedef4", simpleTypedef4Property.getReturnType().getName(),
+ "Incorrect type for property simpleTypedef4.");
+ assertEquals("SimpleTypedef1", simpleTypedef1Property.getReturnType().getName(),
+ "Incorrect type for property simpleTypedef1.");
+ assertEquals("ByteType", byteTypeProperty.getReturnType().getName(), "Incorrect type for property byteType.");
+ assertEquals("TypedefEnumFruit", typedefEnumFruitProperty.getReturnType().getName(),
+ "Incorrect type for property typedefEnumFruit.");
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.Enumeration;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.binding.model.api.Type;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GenEnumResolvingTest {
+class GenEnumResolvingTest {
@Test
- public void testLeafEnumResolving() {
+ void testLeafEnumResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
GenEnumResolvingTest.class,
"/enum-test-models/ietf-interfaces@2012-11-15.yang", "/ietf-models/iana-if-type.yang"));
genInterface = type;
}
}
- assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
+ assertNotNull(genInterface, "Generated Type Interface is not present in list of Generated Types");
Enumeration linkUpDownTrapEnable = null;
Enumeration operStatus = null;
final var enums = genInterface.getEnumerations();
- assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", enums);
- assertEquals("Generated Type Interface MUST contain 2 Enumeration Types", 2, enums.size());
- for (final Enumeration e : enums) {
+ assertNotNull(enums, "Generated Type Interface cannot contain NULL reference to Enumeration types!");
+ assertEquals(2, enums.size(), "Generated Type Interface MUST contain 2 Enumeration Types");
+ for (var e : enums) {
if (e.getName().equals("LinkUpDownTrapEnable")) {
linkUpDownTrapEnable = e;
} else if (e.getName().equals("OperStatus")) {
}
}
- assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
- assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
+ assertNotNull(linkUpDownTrapEnable, "Expected Enum LinkUpDownTrapEnable, but was NULL!");
+ assertNotNull(operStatus, "Expected Enum OperStatus, but was NULL!");
- assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!",
- linkUpDownTrapEnable.getValues());
- assertNotNull("Enum OperStatus MUST contain Values definition not NULL reference!", operStatus.getValues());
- assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2, linkUpDownTrapEnable.getValues().size());
- assertEquals("Enum OperStatus MUST contain 7 values!", 7, operStatus.getValues().size());
+ assertNotNull(linkUpDownTrapEnable.getValues(),
+ "Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!");
+ assertNotNull(operStatus.getValues(), "Enum OperStatus MUST contain Values definition not NULL reference!");
+ assertEquals(2, linkUpDownTrapEnable.getValues().size(), "Enum LinkUpDownTrapEnable MUST contain 2 values!");
+ assertEquals(7, operStatus.getValues().size(), "Enum OperStatus MUST contain 7 values!");
final var methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Interface cannot contain NULL reference for Method Signature Definitions!", methods);
+ assertNotNull(methods, "Generated Interface cannot contain NULL reference for Method Signature Definitions!");
// FIXME: split this into getter/default/static asserts
assertEquals(33, methods.size());
}
}
- assertNotNull("Method getType MUST return Enumeration Type not NULL reference!", ianaIfType);
- assertEquals("Enumeration getType MUST contain 272 values!", 272, ianaIfType.getValues().size());
+ assertNotNull(ianaIfType, "Method getType MUST return Enumeration Type not NULL reference!");
+ assertEquals(272, ianaIfType.getValues().size(), "Enumeration getType MUST contain 272 values!");
}
@Test
- public void testTypedefEnumResolving() {
+ void testTypedefEnumResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/ietf-models/iana-if-type.yang"));
assertNotNull(genTypes);
assertEquals(2, genTypes.size());
- final var type = genTypes.get(1);
- assertThat(type, instanceOf(Enumeration.class));
-
- final var enumer = (Enumeration) type;
- assertEquals("Enumeration type MUST contain 272 values!", 272, enumer.getValues().size());
+ final var type = assertInstanceOf(Enumeration.class, genTypes.get(1));
+ assertEquals(272, type.getValues().size(), "Enumeration type MUST contain 272 values!");
}
@Test
- public void testLeafrefEnumResolving() {
+ void testLeafrefEnumResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
GenEnumResolvingTest.class,
"/enum-test-models/abstract-topology@2013-02-08.yang", "/enum-test-models/ietf-interfaces@2012-11-15.yang",
genInterface = type;
}
}
- assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
+ assertNotNull(genInterface, "Generated Type Interface is not present in list of Generated Types");
- Type linkUpDownTrapEnable = null;
- Type operStatus = null;
+ Enumeration linkUpDownTrapEnable = null;
+ Enumeration operStatus = null;
final var methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", methods);
+ assertNotNull(methods, "Generated Type Interface cannot contain NULL reference to Enumeration types!");
// FIXME: split this into getter/default/static asserts
assertEquals(13, methods.size());
for (var method : methods) {
if (method.getName().equals("getLinkUpDownTrapEnable")) {
- linkUpDownTrapEnable = method.getReturnType();
+ linkUpDownTrapEnable = assertInstanceOf(Enumeration.class, method.getReturnType());
} else if (method.getName().equals("getOperStatus")) {
- operStatus = method.getReturnType();
+ operStatus = assertInstanceOf(Enumeration.class, method.getReturnType());
}
}
- assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
- assertThat(linkUpDownTrapEnable, instanceOf(Enumeration.class));
+ assertNotNull(linkUpDownTrapEnable, "Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!");
assertEquals(
"org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface",
linkUpDownTrapEnable.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
- assertNotNull("Expected Referenced Enum OperStatus, but was NULL!", operStatus);
- assertThat(operStatus, instanceOf(Enumeration.class));
+ assertNotNull(operStatus, "Expected Referenced Enum OperStatus, but was NULL!");
assertEquals(
"org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface",
operStatus.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GenTypesSubSetTest {
+class GenTypesSubSetTest {
@Test
- public void genTypesFromSubsetOfTwoModulesTest() {
+ void genTypesFromSubsetOfTwoModulesTest() {
final var context = YangParserTestUtils.parseYangResources(GenTypesSubSetTest.class,
"/leafref-test-models/abstract-topology@2013-02-08.yang", "/ietf-models/ietf-interfaces.yang",
"/ietf-models/ietf-inet-types.yang", "/ietf-models/ietf-yang-types.yang");
}
}
- assertEquals("Set of to Generate Modules must contain 2 modules", 2, toGenModules.size());
+ assertEquals(2, toGenModules.size(), "Set of to Generate Modules must contain 2 modules");
final var genTypes = DefaultBindingGenerator.generateFor(context, toGenModules);
- assertNotNull("genTypes is null", genTypes);
+ assertNotNull(genTypes, "genTypes is null");
assertEquals(25, genTypes.size());
}
@Test
- public void genTypesFromSubsetOfThreeModulesTest() {
+ void genTypesFromSubsetOfThreeModulesTest() {
final var context = YangParserTestUtils.parseYangResources(GenTypesSubSetTest.class,
"/leafref-test-models/abstract-topology@2013-02-08.yang", "/ietf-models/ietf-interfaces.yang",
"/ietf-models/ietf-inet-types.yang", "/ietf-models/ietf-yang-types.yang",
toGenModules.add(module);
}
}
- assertEquals("Set of to Generate Modules must contain 3 modules", 3, toGenModules.size());
+ assertEquals(3, toGenModules.size(), "Set of to Generate Modules must contain 3 modules");
final var genTypes = DefaultBindingGenerator.generateFor(context, toGenModules);
- assertNotNull("genTypes is null", genTypes);
+ assertNotNull(genTypes, "genTypes is null");
assertEquals(27, genTypes.size());
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.ri.BaseYangTypes;
import org.opendaylight.yangtools.binding.model.ri.Types;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GenerateInnerClassForBitsAndUnionInLeavesTest {
+class GenerateInnerClassForBitsAndUnionInLeavesTest {
@Test
- public void testInnerClassCreationForBitsAndUnionsInLeafes() {
+ void testInnerClassCreationForBitsAndUnionsInLeafes() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/bit_and_union_in_leaf.yang"));
assertEquals(4, genTypes.size());
if (type.getName().equals("ParentContainer")) {
parentContainerFound = true;
GeneratedType parentContainer = type;
- List<GeneratedType> enclosedTypes = parentContainer.getEnclosedTypes();
- for (var genType : enclosedTypes) {
+ for (var genType : parentContainer.getEnclosedTypes()) {
if (genType instanceof GeneratedTransferObject gto) {
if (genType.getName().equals("BitLeaf")) {
- assertFalse("Unexpected duplicate BitLeaf", bitLeafTOFound);
+ assertFalse(bitLeafTOFound, "Unexpected duplicate BitLeaf");
bitLeafTOFound = true;
- List<GeneratedProperty> bitLeafProperties = gto.getProperties();
+ final var bitLeafProperties = gto.getProperties();
assertEquals(3, bitLeafProperties.size());
boolean firstBitPropertyFound = false;
assertTrue(secondBitPropertyFound);
assertTrue(thirdBitPropertyFound);
} else if (genType.getName().equals("UnionLeaf")) {
- assertFalse("Unexpected duplicate UnionLeaf", unionLeafTOFound);
+ assertFalse(unionLeafTOFound, "Unexpected duplicate UnionLeaf");
unionLeafTOFound = true;
- List<GeneratedProperty> unionLeafProperties = gto.getProperties();
+ final var unionLeafProperties = gto.getProperties();
assertEquals(3, unionLeafProperties.size());
boolean int32UnionPropertyFound = false;
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.binding.model.api.MethodSignature.Parameter;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GeneratedTypesBitsTest {
+class GeneratedTypesBitsTest {
@Test
- public void testGeneretedTypesBitsTest() {
+ void testGeneretedTypesBitsTest() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/simple-bits-demo.yang"));
- assertTrue(genTypes != null);
+ assertNotNull(genTypes);
List<MethodSignature> methodSignaturesList = null;
if (genType instanceof GeneratedTransferObject genTO) {
if (genTO.getName().equals("ByteType")) {
byteTypeFound = true;
- List<GeneratedProperty> genProperties = genTO.getProperties();
+ var genProperties = genTO.getProperties();
classPropertiesNumb = genProperties.size();
genProperties = genTO.getToStringIdentifiers();
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertThrows;
-
-import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.contract.Naming;
import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.Type;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GeneratedTypesLeafrefTest {
+class GeneratedTypesLeafrefTest {
@Test
- public void testLeafrefResolving() {
+ void testLeafrefResolving() {
final var context = YangParserTestUtils.parseYangResources(GeneratedTypesLeafrefTest.class,
"/leafref-test-models/abstract-topology@2013-02-08.yang", "/ietf-models/ietf-interfaces.yang",
"/ietf-models/ietf-inet-types.yang", "/ietf-models/ietf-yang-types.yang");
&& "org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces".equals(
type.getPackageName())) {
gtIfcKey = (GeneratedTransferObject) type;
- } else if ("Interface".equals(name)) {
- gtIfc = (GeneratedType) type;
- } else if ("NetworkLink".equals(name)) {
- gtNetworkLink = (GeneratedType) type;
- } else if ("SourceNode".equals(name)) {
- gtSource = (GeneratedType) type;
- } else if ("DestinationNode".equals(name)) {
- gtDest = (GeneratedType) type;
- } else if ("Tunnel".equals(name)) {
- gtTunnel = (GeneratedType) type;
- } else if ("TunnelKey".equals(name)) {
- gtTunnelKey = (GeneratedTransferObject) type;
- } else if ("Topology".equals(name)) {
- gtTopology = (GeneratedType) type;
+ } else {
+ switch (name) {
+ case "Interface":
+ gtIfc = (GeneratedType) type;
+ break;
+ case "NetworkLink":
+ gtNetworkLink = (GeneratedType) type;
+ break;
+ case "SourceNode":
+ gtSource = (GeneratedType) type;
+ break;
+ case "DestinationNode":
+ gtDest = (GeneratedType) type;
+ break;
+ case "Tunnel":
+ gtTunnel = (GeneratedType) type;
+ break;
+ case "TunnelKey":
+ gtTunnelKey = (GeneratedTransferObject) type;
+ break;
+ case "Topology":
+ gtTopology = (GeneratedType) type;
+ break;
+ case null:
+ default:
+ break;
+ }
}
}
}
}
assertNotNull(getIfcKey);
- Type getIfcKeyType = getIfcKey.getReturnType();
+ final var getIfcKeyType = getIfcKey.getReturnType();
assertNotNull(getIfcKeyType);
assertNotSame("java.lang.Void", getIfcKeyType);
assertEquals("InterfaceKey", getIfcKeyType.getName());
assertNotNull(getHigherLayerIf);
- Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
+ final var getHigherLayerIfType = getHigherLayerIf.getReturnType();
assertNotNull(getHigherLayerIfType);
assertNotSame("java.lang.Void", getHigherLayerIfType);
assertEquals("Set", getHigherLayerIfType.getName());
final var gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();
assertNotNull(gtNetworkLinkMethods);
MethodSignature getIfc = null;
- for (MethodSignature method : gtNetworkLinkMethods) {
+ for (var method : gtNetworkLinkMethods) {
if (method.getName().equals("getInterface")) {
getIfc = method;
}
}
assertNotNull(getIfc);
- Type getIfcType = getIfc.getReturnType();
+ final var getIfcType = getIfc.getReturnType();
assertNotNull(getIfcType);
assertNotSame("java.lang.Void", getIfcType);
assertEquals("String", getIfcType.getName());
}
}
assertNotNull(getIdSource);
- Type getIdType = getIdSource.getReturnType();
+ final var getIdType = getIdSource.getReturnType();
assertNotNull(getIdType);
assertNotSame("java.lang.Void", getIdType);
assertEquals("Uri", getIdType.getName());
}
}
assertNotNull(getIdDest);
- Type getIdDestType = getIdDest.getReturnType();
+ final var getIdDestType = getIdDest.getReturnType();
assertNotNull(getIdDestType);
assertNotSame("java.lang.Void", getIdDestType);
assertEquals("Uri", getIdDestType.getName());
}
}
assertNotNull(getTunnelKey);
- Type getTunnelKeyType = getTunnelKey.getReturnType();
+ final var getTunnelKeyType = getTunnelKey.getReturnType();
assertNotNull(getTunnelKeyType);
assertNotSame("java.lang.Void", getTunnelKeyType);
assertEquals("TunnelKey", getTunnelKeyType.getName());
}
}
assertNotNull(tunnelId);
- Type tunnelIdType = tunnelId.getReturnType();
+ final var tunnelIdType = tunnelId.getReturnType();
assertNotNull(tunnelIdType);
assertNotSame("java.lang.Void", tunnelIdType);
assertEquals("Uri", tunnelIdType.getName());
final var uoe = assertThrows(UnsupportedOperationException.class,
() -> DefaultBindingGenerator.generateFor(context));
assertEquals("Cannot ascertain type", uoe.getMessage());
- final var cause = uoe.getCause();
- assertThat(cause, instanceOf(IllegalArgumentException.class));
- assertThat(cause.getMessage(), containsString("Failed to find leafref target"));
+ final var cause = assertInstanceOf(IllegalArgumentException.class, uoe.getCause());
+ assertThat(cause.getMessage()).contains("Failed to find leafref target");
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.List;
import java.util.Map;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.Constant;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.binding.model.api.Type;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GeneratedTypesStringTest {
+class GeneratedTypesStringTest {
@Test
- public void constantGenerationTest() {
+ void constantGenerationTest() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/simple-string-demo.yang"));
if (genTO.getName().equals("TypedefString")) {
typedefStringFound = true;
- List<Constant> constants = genTO.getConstantDefinitions();
- for (Constant con : constants) {
+ for (var con : genTO.getConstantDefinitions()) {
if (con.getName().equals("PATTERN_CONSTANTS")) {
constantRegExListFound = true;
} else {
break;
}
ParameterizedType paramType;
- if (con.getType() instanceof ParameterizedType) {
- paramType = (ParameterizedType) con.getType();
+ if (con.getType() instanceof ParameterizedType parameterized) {
+ paramType = parameterized;
} else {
break;
}
}
- assertTrue("Typedef >>TypedefString<< wasn't found", typedefStringFound);
- assertTrue("Constant PATTERN_CONSTANTS is missing in TO", constantRegExListFound);
- assertTrue("Constant PATTERN_CONSTANTS doesn't have correct container type", constantRegExListTypeContainer);
- assertTrue("Constant PATTERN_CONSTANTS has more than one generic type", constantRegExListTypeOneGeneric);
- assertTrue("Constant PATTERN_CONSTANTS doesn't have correct generic type", constantRegExListTypeGeneric);
- assertTrue("Constant PATTERN_CONSTANTS doesn't contain List object", constantRegExListValueOK);
- assertTrue("In list found other type than String", !noStringInReqExListFound);
+ assertTrue(typedefStringFound, "Typedef >>TypedefString<< wasn't found");
+ assertTrue(constantRegExListFound, "Constant PATTERN_CONSTANTS is missing in TO");
+ assertTrue(constantRegExListTypeContainer, "Constant PATTERN_CONSTANTS doesn't have correct container type");
+ assertTrue(constantRegExListTypeOneGeneric, "Constant PATTERN_CONSTANTS has more than one generic type");
+ assertTrue(constantRegExListTypeGeneric, "Constant PATTERN_CONSTANTS doesn't have correct generic type");
+ assertTrue(constantRegExListValueOK, "Constant PATTERN_CONSTANTS doesn't contain List object");
+ assertFalse(noStringInReqExListFound, "In list found other type than String");
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.contract.Naming;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class GeneratedTypesTest {
+class GeneratedTypesTest {
@Test
- public void testMultipleModulesResolving() {
+ void testMultipleModulesResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResources(GeneratedTypesTest.class,
"/abstract-topology.yang", "/ietf-models/ietf-inet-types.yang"));
}
@Test
- public void testContainerResolving() {
+ void testContainerResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/simple-container-demo.yang"));
}
@Test
- public void testLeafListResolving() {
+ void testLeafListResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/simple-leaf-list-demo.yang"));
}
@Test
- public void testListResolving() {
+ void testListResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/simple-list-demo.yang"));
final var hashProps = genTO.getHashCodeIdentifiers();
final var equalProps = genTO.getEqualsIdentifiers();
- assertEquals("Unexpected key", 0, listKeyClassCount++);
+ assertEquals(0, listKeyClassCount++, "Unexpected key");
assertEquals(1, properties.size());
- assertEquals("listKey", properties.get(0).getName());
- assertEquals("Byte", properties.get(0).getReturnType().getName());
- assertTrue(properties.get(0).isReadOnly());
+ assertEquals("listKey", properties.getFirst().getName());
+ assertEquals("Byte", properties.getFirst().getReturnType().getName());
+ assertTrue(properties.getFirst().isReadOnly());
assertEquals(1, hashProps.size());
- assertEquals("listKey", hashProps.get(0).getName());
- assertEquals("Byte", hashProps.get(0).getReturnType().getName());
+ assertEquals("listKey", hashProps.getFirst().getName());
+ assertEquals("Byte", hashProps.getFirst().getReturnType().getName());
assertEquals(1, equalProps.size());
- assertEquals("listKey", equalProps.get(0).getName());
- assertEquals("Byte", equalProps.get(0).getReturnType().getName());
+ assertEquals("listKey", equalProps.getFirst().getName());
+ assertEquals("Byte", equalProps.getFirst().getReturnType().getName());
}
}
}
@Test
- public void testListCompositeKeyResolving() {
+ void testListCompositeKeyResolving() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/list-composite-key.yang"));
}
@Test
- public void testGeneratedTypes() {
+ void testGeneratedTypes() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/demo-topology.yang"));
}
@Test
- public void testAugmentRpcInput() {
+ void testAugmentRpcInput() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/augment-rpc-input.yang"));
assertEquals(6, genTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
-import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class IdentityrefTypeTest {
- private static List<File> testModels;
+class IdentityrefTypeTest {
+ private List<File> testModels;
- @Before
- public void loadTestResources() throws URISyntaxException {
+ @BeforeEach
+ void loadTestResources() throws Exception {
final var folderFile = Path.of(IdentityrefTypeTest.class.getResource("/identityref.yang").toURI()).toFile();
testModels = new ArrayList<>();
* provideTypeForIdentityref}.
*/
@Test
- public void testIdentityrefYangBuiltInType() {
+ void testIdentityrefYangBuiltInType() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangFiles(testModels));
assertEquals(2, genTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.binding.model.api.MethodSignature;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.ri.Types;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class LeafrefResolutionTest {
+class LeafrefResolutionTest {
@Test
- public void testLeafRefRelativeSelfReference() {
- final EffectiveModelContext schemaContext =
- YangParserTestUtils.parseYangResource("/leafref-relative-invalid.yang");
- final IllegalArgumentException iae = assertThrows(IllegalArgumentException.class,
+ void testLeafRefRelativeSelfReference() {
+ final var schemaContext = YangParserTestUtils.parseYangResource("/leafref-relative-invalid.yang");
+ final var iae = assertThrows(IllegalArgumentException.class,
() -> DefaultBindingGenerator.generateFor(schemaContext));
assertEquals(
"Effective model contains self-referencing leaf (urn:xml:ns:yang:lrr?revision=2015-02-25)neighbor-id",
}
@Test
- public void testLeafRefAbsoluteSelfReference() {
- final EffectiveModelContext schemaContext =
- YangParserTestUtils.parseYangResource("/leafref-absolute-invalid.yang");
- final IllegalArgumentException iae = assertThrows(IllegalArgumentException.class,
+ void testLeafRefAbsoluteSelfReference() {
+ final var schemaContext = YangParserTestUtils.parseYangResource("/leafref-absolute-invalid.yang");
+ final var iae = assertThrows(IllegalArgumentException.class,
() -> DefaultBindingGenerator.generateFor(schemaContext));
assertEquals(
"Effective model contains self-referencing leaf (urn:xml:ns:yang:lra?revision=2015-02-25)neighbor-id",
}
@Test
- public void testLeafRefRelativeAndAbsoluteValidReference() {
- final List<GeneratedType> types = DefaultBindingGenerator.generateFor(
+ void testLeafRefRelativeAndAbsoluteValidReference() {
+ final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/leafref-valid.yang"));
assertEquals(2, types.size());
- final List<MethodSignature> neighborMethods = types.stream()
+ final var neighborMethods = types.stream()
.filter(type -> type.getName().equals("Neighbor"))
.findFirst()
.orElseThrow()
.getMethodDefinitions();
assertEquals(10, neighborMethods.size());
- final MethodSignature getNeighborId = neighborMethods.stream()
+ final var getNeighborId = neighborMethods.stream()
.filter(method -> method.getName().equals("getNeighborId"))
.findFirst()
.orElseThrow();
assertEquals(Types.STRING, getNeighborId.getReturnType());
- final MethodSignature getNeighbor2Id = neighborMethods.stream()
+ final var getNeighbor2Id = neighborMethods.stream()
.filter(method -> method.getName().equals("getNeighbor2Id"))
.findFirst()
.orElseThrow();
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
* Test leafref resolution when the leaf is from a grouping.
*/
-public class Mdsal182Test {
+class Mdsal182Test {
@Test
- public void testOneUpLeafref() {
+ void testOneUpLeafref() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal-182/good-leafref.yang"));
assertEquals(6, types.size());
}
@Test
- public void testTwoUpLeafref() {
+ void testTwoUpLeafref() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal-182/grouping-leafref.yang"));
assertEquals(4, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal300Test {
+class Mdsal300Test {
@Test
- public void testActionsAndAugmentsTest() {
- List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(
+ void testActionsAndAugmentsTest() {
+ final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-300"));
- assertNotNull(generateTypes);
- assertEquals(19, generateTypes.size());
+ assertNotNull(types);
+ assertEquals(19, types.size());
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal302Test {
+class Mdsal302Test {
@Test
- public void testRpcUsesAugment() {
+ void testRpcUsesAugment() {
final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal302.yang"));
assertNotNull(types);
assertEquals(15, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.Iterator;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.contract.Naming;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.binding.model.api.MethodSignature;
-import org.opendaylight.yangtools.binding.model.api.Type;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal320Test {
+class Mdsal320Test {
@Test
- public void mdsal320Test() {
+ void mdsal320Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal320.yang"));
assertEquals(2, generateTypes.size());
- final GeneratedType foo = generateTypes.stream().filter(type -> type.getFullyQualifiedName()
+ final var foo = generateTypes.stream().filter(type -> type.getFullyQualifiedName()
.equals("org.opendaylight.yang.gen.v1.urn.odl.yt320.norev.Foo")).findFirst().orElseThrow();
- final List<GeneratedType> fooTypes = foo.getEnclosedTypes();
+ final var fooTypes = foo.getEnclosedTypes();
assertEquals(1, fooTypes.size());
- final GeneratedType bar = fooTypes.get(0);
+ final var bar = assertInstanceOf(GeneratedTransferObject.class, fooTypes.getFirst());
assertEquals("Bar", bar.getName());
- assertThat(bar, instanceOf(GeneratedTransferObject.class));
- assertTrue(((GeneratedTransferObject) bar).isUnionType());
+ assertTrue(bar.isUnionType());
- final List<GeneratedType> barTypes = bar.getEnclosedTypes();
+ final var barTypes = bar.getEnclosedTypes();
assertEquals(1, barTypes.size());
- final GeneratedType bar1 = barTypes.get(0);
+ final var bar1 = assertInstanceOf(GeneratedTransferObject.class, barTypes.getFirst());
assertEquals("Bar$1", bar1.getName());
- assertThat(bar1, instanceOf(GeneratedTransferObject.class));
- assertTrue(((GeneratedTransferObject) bar1).isUnionType());
+ assertTrue(bar1.isUnionType());
- final Iterator<MethodSignature> it = foo.getMethodDefinitions().iterator();
+ final var it = foo.getMethodDefinitions().iterator();
assertTrue(it.hasNext());
- final MethodSignature getImplIface = it.next();
+ final var getImplIface = it.next();
assertEquals("implementedInterface", getImplIface.getName());
assertTrue(getImplIface.isDefault());
assertTrue(it.hasNext());
- final MethodSignature bindingHashCode = it.next();
+ final var bindingHashCode = it.next();
assertEquals(Naming.BINDING_HASHCODE_NAME, bindingHashCode.getName());
- final MethodSignature bindingEquals = it.next();
+ final var bindingEquals = it.next();
assertEquals(Naming.BINDING_EQUALS_NAME, bindingEquals.getName());
- final MethodSignature bindingToString = it.next();
+ final var bindingToString = it.next();
assertEquals(Naming.BINDING_TO_STRING_NAME, bindingToString.getName());
- final MethodSignature getBar = it.next();
- final Type getBarType = getBar.getReturnType();
- assertTrue(getBarType instanceof GeneratedTransferObject);
- final GeneratedTransferObject getBarTO = (GeneratedTransferObject) getBarType;
- assertTrue(getBarTO.isUnionType());
- assertEquals(bar, getBarTO);
- final MethodSignature requireBar = it.next();
- assertThat(requireBar.getName(), startsWith(Naming.REQUIRE_PREFIX));
+ final var getBar = it.next();
+ final var getBarType = assertInstanceOf(GeneratedTransferObject.class, getBar.getReturnType());
+ assertTrue(getBarType.isUnionType());
+ assertEquals(bar, getBarType);
+ final var requireBar = it.next();
+ assertThat(requireBar.getName()).startsWith(Naming.REQUIRE_PREFIX);
assertFalse(it.hasNext());
- final GeneratedProperty bar1Prop = bar.getProperties().stream().filter(prop -> "bar$1".equals(prop.getName()))
+ final var bar1Prop = bar.getProperties().stream().filter(prop -> "bar$1".equals(prop.getName()))
.findFirst().orElseThrow();
- final Type bar1PropRet = bar1Prop.getReturnType();
- assertEquals(bar1, bar1PropRet);
+ assertEquals(bar1, bar1Prop.getReturnType());
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal324Test {
+class Mdsal324Test {
@Test
- public void mdsal324Test() {
+ void mdsal324Test() {
final var generatedTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal324.yang"));
assertEquals(2, generatedTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import org.junit.Test;
+import java.util.List;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal332Test {
+class Mdsal332Test {
@Test
- public void mdsal332Test() {
+ void mdsal332Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal332.yang"));
assertNotNull(generateTypes);
assertEquals(5, generateTypes.size());
- final var names = generateTypes.stream().map(GeneratedType::getIdentifier)
- .collect(ImmutableList.toImmutableList());
+ final var names = generateTypes.stream().map(GeneratedType::getIdentifier).toList();
final var uniqueNames = ImmutableSet.copyOf(names);
- assertEquals(ImmutableList.copyOf(uniqueNames), names);
+ assertEquals(List.copyOf(uniqueNames), names);
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal335Test {
+class Mdsal335Test {
@Test
- public void mdsal335Test() {
+ void mdsal335Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal335.yang"));
assertNotNull(generateTypes);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal352Test {
+class Mdsal352Test {
@Test
- public void mdsal352Test() {
+ void mdsal352Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal352.yang"));
assertNotNull(generateTypes);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.opendaylight.yangtools.binding.model.ri.BindingTypes.BITS_TYPE_OBJECT;
import static org.opendaylight.yangtools.binding.model.ri.BindingTypes.UNION_TYPE_OBJECT;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.ri.BindingTypes;
import org.opendaylight.yangtools.binding.model.ri.Types;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal406TypeObjectTest {
+class Mdsal406TypeObjectTest {
private static EffectiveModelContext CONTEXT;
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
CONTEXT = YangParserTestUtils.parseYangResources(ExtendedTypedefTest.class,
"/type-provider/test.yang", "/ietf-models/ietf-inet-types.yang");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
CONTEXT = null;
}
@Test
- public void typeObjectTest() {
+ void typeObjectTest() {
final var generateTypes = DefaultBindingGenerator.generateFor(CONTEXT);
assertNotNull(generateTypes);
}
@Test
- public void bitsTypeObjectForBitsTypedefTest() {
+ void bitsTypeObjectForBitsTypedefTest() {
final var generateTypes = DefaultBindingGenerator.generateFor(CONTEXT);
assertNotNull(generateTypes);
}
@Test
- public void typeObjectForUnionTypedefTest() {
+ void typeObjectForUnionTypedefTest() {
final var generateTypes = DefaultBindingGenerator.generateFor(CONTEXT);
assertNotNull(generateTypes);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal437Test extends AbstractOpaqueTest {
+class Mdsal437Test extends AbstractOpaqueTest {
@Test
- public void generateAnyxmlTest() {
+ void generateAnyxmlTest() {
final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal437.yang"));
assertNotNull(types);
assertEquals(7, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal438Test extends AbstractOpaqueTest {
+class Mdsal438Test extends AbstractOpaqueTest {
@Test
- public void generateAnydataTest() {
- final List<GeneratedType> types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
- "/mdsal438.yang"));
+ void generateAnydataTest() {
+ final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal438.yang"));
assertNotNull(types);
assertEquals(7, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import com.google.common.collect.ImmutableSet;
+import java.util.Set;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal458Test {
+class Mdsal458Test {
@Test
- public void testNestedClassFallback() {
+ void testNestedClassFallback() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal458.yang"));
assertEquals(2, types.size());
final var typeNames = types.stream().map(GeneratedType::getIdentifier).collect(Collectors.toSet());
- assertEquals(ImmutableSet.of(
+ assertEquals(Set.of(
JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal458.norev", "ExportedTo"),
JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal458.norev", "Mdsal458Data")), typeNames);
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import com.google.common.collect.ImmutableSet;
+import java.util.Set;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal459Test {
+class Mdsal459Test {
@Test
- public void testAugmentedAction() {
+ void testAugmentedAction() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-459/"));
assertNotNull(types);
assertEquals(7, types.size());
final var typeNames = types.stream().map(GeneratedType::getIdentifier).collect(Collectors.toSet());
- assertEquals(ImmutableSet.of(
+ assertEquals(Set.of(
JavaTypeName.create("org.opendaylight.yang.gen.v1.base.norev", "Foo"),
JavaTypeName.create("org.opendaylight.yang.gen.v1.base.norev", "BaseData"),
JavaTypeName.create("org.opendaylight.yang.gen.v1.aug.norev", "AugData"),
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal499Test {
+class Mdsal499Test {
@Test
- public void testSubmoduleImport() {
+ void testSubmoduleImport() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-499"));
assertNotNull(generateTypes);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal500Test {
+class Mdsal500Test {
@Test
- public void testAugmentedAction() {
+ void testAugmentedAction() {
final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal500.yang"));
assertNotNull(types);
assertEquals(4, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal506Test extends AbstractOpaqueTest {
+class Mdsal506Test extends AbstractOpaqueTest {
@Test
- public void generateAnydataTest() {
+ void generateAnydataTest() {
final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal506.yang"));
assertNotNull(types);
assertEquals(4, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal516Test {
+class Mdsal516Test {
@Test
- public void testGroupingActionType() {
+ void testGroupingActionType() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-516"));
assertNotNull(types);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal517Test extends AbstractOpaqueTest {
+class Mdsal517Test extends AbstractOpaqueTest {
@Test
- public void augmentActionInputInGroupingTest() {
+ void augmentActionInputInGroupingTest() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-517"));
assertNotNull(types);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
* Test specific combination of leafrefs, grouping and relative paths.
*/
-public class Mdsal519Test {
+class Mdsal519Test {
@Test
- public void testNestedLeafref2() {
+ void testNestedLeafref2() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal519.yang"));
assertNotNull(types);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal531Test extends AbstractOpaqueTest {
+class Mdsal531Test extends AbstractOpaqueTest {
@Test
- public void augmentGroupingTest() {
+ void augmentGroupingTest() {
final var types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-531"));
assertNotNull(types);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal552Test {
+class Mdsal552Test {
private static final JavaTypeName BAR_INPUT =
JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal552.norev", "BarInput");
private static final JavaTypeName BAZ =
JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal552.norev", "Mdsal552Data").createEnclosed("Foo");
@Test
- public void enumLeafrefTest() {
+ void enumLeafrefTest() {
final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal552.yang"));
assertNotNull(types);
assertEquals(5, types.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal554Test {
+class Mdsal554Test {
@Test
- public void builderTemplateGenerateListenerMethodsTest() {
+ void builderTemplateGenerateListenerMethodsTest() {
final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal554.yang"));
assertEquals(4, genTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal572Test {
+class Mdsal572Test {
@Test
- public void mdsal572Test() {
+ void mdsal572Test() {
final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal572.yang"));
assertEquals(5, types.size());
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal573Test {
+class Mdsal573Test {
@Test
- public void mdsal573Test() {
+ void mdsal573Test() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal573.yang"));
assertNotNull(generateTypes);
assertEquals(7, generateTypes.size());
- final var methodSignature = generateTypes.get(0).getMethodDefinitions().get(0);
+ final var methodSignature = generateTypes.getFirst().getMethodDefinitions().getFirst();
assertEquals("implementedInterface", methodSignature.getName());
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@NonNullByDefault
-public class Mdsal600Test {
+class Mdsal600Test {
private static final JavaTypeName FOO = JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal600.norev", "Foo");
@Test
- public void mdsal600Test() {
+ void mdsal600Test() {
final var models = YangParserTestUtils.parseYangResource("/mdsal600.yang");
final var module = models.getModules().iterator().next();
final var fooSchema = (ContainerSchemaNode) module.findDataTreeChild(QName.create("mdsal600", "foo"))
.orElseThrow();
// Verify leaves
- final var barSchema = fooSchema.findDataTreeChild(QName.create("mdsal600", "bar")).orElseThrow();
- final var bazSchema = fooSchema.findDataTreeChild(QName.create("mdsal600", "baz")).orElseThrow();
- final var barTypeSchema = ((LeafSchemaNode) barSchema).getType();
- final var bazTypeSchema = ((LeafSchemaNode) bazSchema).getType();
+ final var barSchema = assertInstanceOf(LeafSchemaNode.class,
+ fooSchema.findDataTreeChild(QName.create("mdsal600", "bar")).orElseThrow());
+ final var bazSchema = assertInstanceOf(LeafSchemaNode.class,
+ fooSchema.findDataTreeChild(QName.create("mdsal600", "baz")).orElseThrow());
+ final var barTypeSchema = barSchema.getType();
+ final var bazTypeSchema = bazSchema.getType();
// Precondition to our bug: the two types compare as equal, but are not the same
assertEquals(barTypeSchema, bazTypeSchema);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal666Test {
+class Mdsal666Test {
private static final JavaTypeName FOO = JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev", "Foo");
private static final JavaTypeName FOO_GRP = JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev", "Foo$G");
private static final JavaTypeName BAZ_GRP = JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.bar",
"Baz$G");
@Test
- public void rpcPushesGrouping() {
+ void rpcPushesGrouping() {
final var generatedNames = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/mdsal666.yang")).stream().map(GeneratedType::getIdentifier)
.collect(Collectors.toUnmodifiableList());
assertEquals(10, generatedNames.size());
// 'rpc foo' ...
- assertTrue(generatedNames.stream().anyMatch(FOO::equals));
+ assertThat(generatedNames).anyMatch(FOO::equals);
// ... grouping is relocated for 'rpc foo' ...
- assertTrue(generatedNames.stream().anyMatch(FOO_GRP::equals));
+ assertThat(generatedNames).anyMatch(FOO_GRP::equals);
// .. and 'action baz'
- assertTrue(generatedNames.stream().anyMatch(BAZ_GRP::equals));
+ assertThat(generatedNames).anyMatch(BAZ_GRP::equals);
}
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.in;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import java.util.function.Function;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.binding.model.api.Type;
import org.opendaylight.yangtools.binding.model.ri.Types;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal675Test {
+class Mdsal675Test {
private static final String PACKAGE = "org.opendaylight.yang.gen.v1.urn.test.yang.data.demo.norev.";
private static final String PACKAGE2 = "org.opendaylight.yang.gen.v1.urn.test.yang.data.naming.norev.";
private static final String MODULE_CLASS_NAME = PACKAGE + "YangDataDemoData";
Map.of("implementedInterface", Types.typeForClass(Class.class));
@Test
- public void yangDataGen() {
- final List<GeneratedType> allGenTypes = DefaultBindingGenerator.generateFor(
+ void yangDataGen() {
+ final var allGenTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResources(Mdsal675Test.class,
"/yang-data-models/ietf-restconf.yang", "/yang-data-models/yang-data-demo.yang"));
assertNotNull(allGenTypes);
assertEquals(29, allGenTypes.size());
- final Map<String, GeneratedType> genTypesMap = allGenTypes.stream()
- .collect(ImmutableMap.toImmutableMap(type -> type.getIdentifier().toString(), type -> type));
+ final var genTypesMap = allGenTypes.stream()
+ .collect(ImmutableMap.toImmutableMap(type -> type.getIdentifier().toString(), Function.identity()));
// ensure generated yang-data classes contain getters for inner structure types
List.of("getAnyxmlFromGroup", "requireAnyxmlFromGroup"));
// ensure module class has only getter for root container
- final GeneratedType moduleType = assertGenType(genTypesMap, MODULE_CLASS_NAME);
+ final var moduleType = assertGenType(genTypesMap, MODULE_CLASS_NAME);
assertNotNull(moduleType.getMethodDefinitions());
assertEquals(List.of("getRootContainer"),
moduleType.getMethodDefinitions().stream().map(MethodSignature::getName)
.filter(methodName -> methodName.startsWith("get")).toList());
// ensure yang-data at non-top level is ignored (no getters in parent container)
- GeneratedType rootContainerType = assertGenType(genTypesMap, ROOT_CONTAINER_CLASS_NAME);
+ final var rootContainerType = assertGenType(genTypesMap, ROOT_CONTAINER_CLASS_NAME);
assertNotNull(rootContainerType.getMethodDefinitions());
- assertTrue(rootContainerType.getMethodDefinitions().stream()
- .filter(method -> method.getName().startsWith("get"))
- .findFirst().isEmpty());
+ assertThat(rootContainerType.getMethodDefinitions()).noneMatch(method -> method.getName().startsWith("get"));
}
@Test
- public void yangDataNamingStrategy() {
- final List<GeneratedType> allGenTypes = DefaultBindingGenerator.generateFor(
+ void yangDataNamingStrategy() {
+ final var allGenTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResources(Mdsal675Test.class,
"/yang-data-models/ietf-restconf.yang", "/yang-data-models/yang-data-naming.yang"));
assertNotNull(allGenTypes);
assertEquals(22, allGenTypes.size());
- final Set<String> genTypeNames =
- allGenTypes.stream().map(type -> type.getIdentifier().toString()).collect(Collectors.toSet());
+ final var genTypeNames = allGenTypes.stream().map(type -> type.getIdentifier().toString())
+ .collect(Collectors.toSet());
// template name is not compliant to YANG identifier -> char encoding used, name starts with $ char
// a) latin1, but not a valid Java identifier
- assertTrue(genTypeNames.contains(PACKAGE2 + "$ľaľa$20$ho$2C$$20$papľuha$2C$$20$ogrcal$20$mi$20$krpce$21$"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "$ľaľa$20$ho$2C$$20$papľuha$2C$$20$ogrcal$20$mi$20$krpce$21$");
// b) cyrillic, but a valid Java identifier
- assertTrue(genTypeNames.contains(PACKAGE2 + "привет"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "привет");
// template name is compliant to yang identifier -> camel-case used
- assertTrue(genTypeNames.contains(PACKAGE2 + "IdentifierCompliantName"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "IdentifierCompliantName");
// name collision with a typedef
- assertTrue(genTypeNames.contains(PACKAGE2 + "Collision1$T"));
- assertTrue(genTypeNames.contains(PACKAGE2 + "collision1.Collision1"));
- assertTrue(genTypeNames.contains(PACKAGE2 + "Collision1$YD"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "Collision1$T");
+ assertThat(genTypeNames).contains(PACKAGE2 + "collision1.Collision1");
+ assertThat(genTypeNames).contains(PACKAGE2 + "Collision1$YD");
// name collision with top level container
- assertTrue(genTypeNames.contains(PACKAGE2 + "Collision2"));
- assertTrue(genTypeNames.contains(PACKAGE2 + "Collision2$YD"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "Collision2");
+ assertThat(genTypeNames).contains(PACKAGE2 + "Collision2$YD");
// name collision with group used
- assertTrue(genTypeNames.contains(PACKAGE2 + "Collision3$G"));
- assertTrue(genTypeNames.contains(PACKAGE2 + "Collision3$YD"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "Collision3$G");
+ assertThat(genTypeNames).contains(PACKAGE2 + "Collision3$YD");
// rc:yang-data .-/#
- assertTrue(genTypeNames.contains(PACKAGE2 + "$$2E$$2D$$2F$$23$"));
- assertTrue(genTypeNames.contains(PACKAGE2 + "$$2e$$2d$$2f$$23$$.Foo"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "$$2E$$2D$$2F$$23$");
+ assertThat(genTypeNames).contains(PACKAGE2 + "$$2e$$2d$$2f$$23$$.Foo");
// rc:yang-data -./#
- assertTrue(genTypeNames.contains(PACKAGE2 + "$$2D$$2E$$2F$$23$"));
- assertTrue(genTypeNames.contains(PACKAGE2 + "$$2d$$2e$$2f$$23$$.Foo"));
+ assertThat(genTypeNames).contains(PACKAGE2 + "$$2D$$2E$$2F$$23$");
+ assertThat(genTypeNames).contains(PACKAGE2 + "$$2d$$2e$$2f$$23$$.Foo");
}
private static GeneratedType assertGenType(final Map<String, GeneratedType> genTypesMap, final String className) {
final var ret = genTypesMap.get(className);
- assertNotNull("no type generated: " + className, ret);
+ assertNotNull(ret, "no type generated: " + className);
return ret;
}
private static void assertHasMethod(final GeneratedType genType, final String methodName,
final Type returnType) {
- assertTrue("no expected method " + methodName + " returning " + returnType,
- genType.getMethodDefinitions().stream().anyMatch(
- method -> methodName.equals(method.getName()) && returnType.equals(method.getReturnType())));
+ assertThat(genType.getMethodDefinitions())
+ .anyMatch(method -> methodName.equals(method.getName()) && returnType.equals(method.getReturnType()));
}
private static void assertImplements(final GeneratedType genType, final Type implementedType) {
- assertThat(implementedType, in(genType.getImplements()));
+ assertThat(genType.getImplements()).contains(implementedType);
}
-
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal715Test {
+class Mdsal715Test {
@Test
- public void testAugmentLinking() {
+ void testAugmentLinking() {
final var generatedTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal715"));
assertEquals(15, generatedTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal718Test {
+class Mdsal718Test {
@Test
- public void testModuleUsesAugmentLinking() {
+ void testModuleUsesAugmentLinking() {
final var generatedTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal718"));
assertEquals(13, generatedTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal810Test {
+class Mdsal810Test {
@Test
- public void testKeyConflict() {
+ void testKeyConflict() {
assertGeneratedNames("key-conflict.yang",
"org.opendaylight.yang.gen.v1.key.conflict.norev.KeyConflictData",
"org.opendaylight.yang.gen.v1.key.conflict.norev.Foo$LI",
}
@Test
- public void testListenerConflict() {
+ void testListenerConflict() {
assertGeneratedNames("listener-conflict.yang",
"org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictData",
"org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictListener",
}
@Test
- public void testRootConflict() {
+ void testRootConflict() {
assertGeneratedNames("root-conflict.yang",
"org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData",
"org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData$CO");
}
@Test
- public void testServiceConflict() {
+ void testServiceConflict() {
assertGeneratedNames("service-conflict.yang",
"org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictData",
"org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictService",
}
@Test
- public void testInputOutputConflict() {
+ void testInputOutputConflict() {
assertGeneratedNames("io-conflict.yang",
"org.opendaylight.yang.gen.v1.io.conflict.norev.IoConflictData",
"org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RP",
}
@Test
- public void testSchemaCollisions() {
+ void testSchemaCollisions() {
assertGeneratedNames("schema-conflict.yang",
"org.opendaylight.yang.gen.v1.schema.conflict.norev.SchemaConflictData",
"org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$AD",
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.binding.runtime.api.ActionRuntimeType;
import org.opendaylight.yangtools.binding.runtime.api.ContainerRuntimeType;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal824Test {
+class Mdsal824Test {
private static EffectiveModelContext CONTEXT;
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/mdsal824");
}
@Test
- public void testCompileTimeTypes() {
+ void testCompileTimeTypes() {
assertEquals(13, DefaultBindingGenerator.generateFor(CONTEXT).size());
}
@Test
- public void testRunTimeTypes() {
+ void testRunTimeTypes() {
final var types = BindingRuntimeTypesFactory.createTypes(CONTEXT);
- final var barTop = types.schemaTreeChild(QName.create("bar", "bar-top"));
- assertThat(barTop, instanceOf(ContainerRuntimeType.class));
- final var barList = ((ContainerRuntimeType) barTop).schemaTreeChild(QName.create("bar", "bar-list"));
- assertThat(barList, instanceOf(ListRuntimeType.class));
- final var barAction = ((ListRuntimeType) barList).schemaTreeChild(QName.create("bar", "foo"));
- assertThat(barAction, instanceOf(ActionRuntimeType.class));
-
- final var barInput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "input"));
- assertThat(barInput, instanceOf(InputRuntimeType.class));
+ final var barTop = assertInstanceOf(ContainerRuntimeType.class,
+ types.schemaTreeChild(QName.create("bar", "bar-top")));
+ final var barList = assertInstanceOf(ListRuntimeType.class,
+ barTop.schemaTreeChild(QName.create("bar", "bar-list")));
+ final var barAction = assertInstanceOf(ActionRuntimeType.class,
+ barList.schemaTreeChild(QName.create("bar", "foo")));
+
+ final var barInput = assertInstanceOf(InputRuntimeType.class,
+ barAction.schemaTreeChild(QName.create("bar", "input")));
assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooInput"),
barInput.javaType().getIdentifier());
- final var barOutput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "output"));
- assertThat(barOutput, instanceOf(OutputRuntimeType.class));
+ final var barOutput = assertInstanceOf(OutputRuntimeType.class,
+ barAction.schemaTreeChild(QName.create("bar", "output")));
assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooOutput"),
barOutput.javaType().getIdentifier());
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class Mdsal829Test {
+class Mdsal829Test {
private static final EffectiveModelContext MODEL_CONTEXT =
YangParserTestUtils.parseYangResource("/mdsal829.yang", Set.of());
@Test
- public void testCompileTimeTypes() {
+ void testCompileTimeTypes() {
assertEquals(1, DefaultBindingGenerator.generateFor(MODEL_CONTEXT).size());
}
@Test
- public void testRunTimeTypes() {
+ void testRunTimeTypes() {
final var types = BindingRuntimeTypesFactory.createTypes(MODEL_CONTEXT);
assertSame(MODEL_CONTEXT, types.modelContext());
final var schema = types.findSchema(
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.Serializable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.generator.impl.reactor.SerialVersionHelper;
import org.opendaylight.yangtools.binding.model.api.AccessModifier;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
-import org.opendaylight.yangtools.binding.model.api.type.builder.GeneratedTypeBuilder;
-import org.opendaylight.yangtools.binding.model.api.type.builder.MethodSignatureBuilder;
import org.opendaylight.yangtools.binding.model.ri.Types;
import org.opendaylight.yangtools.binding.model.ri.generated.type.builder.CodegenGeneratedTOBuilder;
import org.opendaylight.yangtools.binding.model.ri.generated.type.builder.CodegenGeneratedTypeBuilder;
-public class SerialVersionHelperTest {
+class SerialVersionHelperTest {
@Test
- public void computeDefaultSUIDTest() {
- CodegenGeneratedTypeBuilder generatedTypeBuilder = new CodegenGeneratedTypeBuilder(
+ void computeDefaultSUIDTest() {
+ final var generatedTypeBuilder = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("my.package", "MyName"));
- MethodSignatureBuilder method = generatedTypeBuilder.addMethod("myMethodName");
+ final var method = generatedTypeBuilder.addMethod("myMethodName");
method.setAccessModifier(AccessModifier.PUBLIC);
generatedTypeBuilder.addProperty("myProperty");
generatedTypeBuilder.addImplementsType(Types.typeForClass(Serializable.class));
}
@Test
- public void computeDefaultSUIDStabilityTest() {
+ void computeDefaultSUIDStabilityTest() {
// test method computeDefaultSUID
- GeneratedTypeBuilder genTypeBuilder = new CodegenGeneratedTypeBuilder(
+ final var genTypeBuilder = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("org.opendaylight.yangtools.test", "TestType"));
genTypeBuilder.addMethod("testMethod");
genTypeBuilder.addAnnotation("org.opendaylight.yangtools.test.annotation", "AnnotationTest");
genTypeBuilder.addEnclosingTransferObject(new CodegenGeneratedTOBuilder(genTypeBuilder.getIdentifier()
.createEnclosed("testObject")).build());
genTypeBuilder.addProperty("newProp");
- GeneratedTypeBuilder genType = new CodegenGeneratedTypeBuilder(
+ final var genType = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("org.opendaylight.yangtools.test", "Type2"));
genTypeBuilder.addImplementsType(genType);
long computedSUID = SerialVersionHelper.computeDefaultSUID(genTypeBuilder);
- GeneratedTypeBuilder genTypeBuilder2 = new CodegenGeneratedTypeBuilder(
+ final var genTypeBuilder2 = new CodegenGeneratedTypeBuilder(
JavaTypeName.create("org.opendaylight.yangtools.test2", "TestType2"));
long computedSUID2 = SerialVersionHelper.computeDefaultSUID(genTypeBuilder2);
assertNotEquals(computedSUID, computedSUID2);
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.binding.model.api.Type;
-public final class SupportTestUtil {
+final class SupportTestUtil {
private SupportTestUtil() {
-
+ // Hidden on purpose
}
- public static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
- final List<MethodSignature> searchedSignsIn = genType.getMethodDefinitions();
- containsMethods(searchedSignsIn, searchedSignsWhat);
+ static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
+ containsMethods(genType.getMethodDefinitions(), searchedSignsWhat);
}
- public static void containsMethods(final List<MethodSignature> searchedSignsIn,
+ static void containsMethods(final List<MethodSignature> searchedSignsIn,
final NameTypePattern... searchedSignsWhat) {
if (searchedSignsIn == null) {
throw new IllegalArgumentException("List of method signatures in which should be searched can't be null");
throw new IllegalArgumentException("Array of method signatures which should be searched can't be null");
}
- for (NameTypePattern searchedSignWhat : searchedSignsWhat) {
+ for (var searchedSignWhat : searchedSignsWhat) {
boolean nameMatchFound = false;
String typeNameFound = "";
- for (MethodSignature searchedSignIn : searchedSignsIn) {
+ for (var searchedSignIn : searchedSignsIn) {
if (searchedSignWhat.getName().equals(searchedSignIn.getName())) {
nameMatchFound = true;
typeNameFound = resolveFullNameOfReturnType(searchedSignIn.getReturnType());
}
}
}
- assertTrue("Method " + searchedSignWhat.getName() + " wasn't found.", nameMatchFound);
- assertEquals("Return type in method " + searchedSignWhat.getName() + " doesn't match expected type ",
- searchedSignWhat.getType(), typeNameFound);
+ assertTrue(nameMatchFound, "Method " + searchedSignWhat.getName() + " wasn't found.");
+ assertEquals(searchedSignWhat.getType(), typeNameFound,
+ "Return type in method " + searchedSignWhat.getName() + " doesn't match expected type ");
}
}
- public static void containsAttributes(final GeneratedTransferObject genTO, final boolean equal, final boolean hash,
+ static void containsAttributes(final GeneratedTransferObject genTO, final boolean equal, final boolean hash,
final boolean toString, final NameTypePattern... searchedSignsWhat) {
- List<GeneratedProperty> searchedPropertiesIn = genTO.getProperties();
+ var searchedPropertiesIn = genTO.getProperties();
containsAttributes(searchedPropertiesIn, "", searchedSignsWhat);
if (equal) {
searchedPropertiesIn = genTO.getEqualsIdentifiers();
searchedPropertiesIn = genTO.getToStringIdentifiers();
containsAttributes(searchedPropertiesIn, "toString", searchedSignsWhat);
}
-
}
- public static void containsAttributes(final List<GeneratedProperty> searchedPropertiesIn, final String listType,
+ static void containsAttributes(final List<GeneratedProperty> searchedPropertiesIn, final String listType,
final NameTypePattern... searchedPropertiesWhat) {
- for (NameTypePattern searchedPropertyWhat : searchedPropertiesWhat) {
+ for (var searchedPropertyWhat : searchedPropertiesWhat) {
boolean nameMatchFound = false;
String typeNameFound = "";
- for (GeneratedProperty searchedPropertyIn : searchedPropertiesIn) {
+ for (var searchedPropertyIn : searchedPropertiesIn) {
if (searchedPropertyWhat.getName().equals(searchedPropertyIn.getName())) {
nameMatchFound = true;
typeNameFound = resolveFullNameOfReturnType(searchedPropertyIn.getReturnType());
}
}
}
- assertTrue("Property " + searchedPropertyWhat.getName() + " wasn't found in " + listType
- + " property list.", nameMatchFound);
- assertEquals("The type of property " + searchedPropertyWhat.getName() + " in " + listType
- + " property list doesn't match expected type.", searchedPropertyWhat.getType(), typeNameFound);
-
+ assertTrue(nameMatchFound,
+ "Property " + searchedPropertyWhat.getName() + " wasn't found in " + listType + " property list.");
+ assertEquals(searchedPropertyWhat.getType(), typeNameFound,
+ "The type of property " + searchedPropertyWhat.getName() + " in " + listType
+ + " property list doesn't match expected type.");
}
}
- public static String resolveFullNameOfReturnType(final Type type) {
- final StringBuilder nameBuilder = new StringBuilder();
- if (type instanceof ParameterizedType) {
- nameBuilder.append(type.getName()).append('<');
- ParameterizedType parametrizedTypes = (ParameterizedType) type;
- for (Type parametrizedType : parametrizedTypes.getActualTypeArguments()) {
- nameBuilder.append(parametrizedType.getName()).append(',');
+ static String resolveFullNameOfReturnType(final Type type) {
+ final var sb = new StringBuilder();
+ if (type instanceof ParameterizedType parameterizedTypes) {
+ sb.append(type.getName()).append('<');
+ for (var parameterizedType : parameterizedTypes.getActualTypeArguments()) {
+ sb.append(parameterizedType.getName()).append(',');
}
- if (nameBuilder.charAt(nameBuilder.length() - 1) == ',') {
- nameBuilder.deleteCharAt(nameBuilder.length() - 1);
+ if (sb.charAt(sb.length() - 1) == ',') {
+ sb.deleteCharAt(sb.length() - 1);
}
- nameBuilder.append(">");
+ sb.append(">");
} else {
- nameBuilder.append(type.getName());
+ sb.append(type.getName());
}
- return nameBuilder.toString();
+ return sb.toString();
}
- public static void containsInterface(final String interfaceNameSearched, final GeneratedType genType) {
- List<Type> caseCImplements = genType.getImplements();
+ static void containsInterface(final String interfaceNameSearched, final GeneratedType genType) {
+ final var caseCImplements = genType.getImplements();
boolean interfaceFound = false;
- for (Type caseCImplement : caseCImplements) {
- String interfaceName = resolveFullNameOfReturnType(caseCImplement);
- if (interfaceName.equals(interfaceNameSearched)) {
+ for (var caseCImplement : caseCImplements) {
+ if (resolveFullNameOfReturnType(caseCImplement).equals(interfaceNameSearched)) {
interfaceFound = true;
break;
}
}
- assertTrue("Generated type " + genType.getName() + " doesn't implement interface " + interfaceNameSearched,
- interfaceFound);
+ assertTrue(interfaceFound,
+ "Generated type " + genType.getName() + " doesn't implement interface " + interfaceNameSearched);
}
-
}
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.ri.Types;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class UnionTypeDefTest {
+class UnionTypeDefTest {
@Test
- public void unionTypeResolvingTest() {
+ void unionTypeResolvingTest() {
final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
UnionTypeDefTest.class, "/union-test-models/abstract-topology.yang", "/ietf-models/ietf-inet-types.yang"));
assertEquals(29, genTypes.size());
}
@Test
- public void unionTypedefLeafrefTest() {
+ void unionTypedefLeafrefTest() {
final var generateTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/bug8449.yang"));
assertEquals(5, generateTypes.size());
*/
package org.opendaylight.yangtools.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsInterface;
import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsMethods;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class UsesTest {
+class UsesTest {
@Test
- public void usesInGroupingDependenciesTest() {
+ void usesInGroupingDependenciesTest() {
final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-dependencies.yang"));
GeneratedType groupingU = null;
}
}
- assertNotNull("Generated type for grouping-U wasn't generated.", groupingU);
- assertEquals("GroupingU interface generated more than one time.", 1, groupingUCounter);
- assertEquals("GroupingU is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingU.getPackageName());
+ assertNotNull(groupingU, "Generated type for grouping-U wasn't generated.");
+ assertEquals(1, groupingUCounter, "GroupingU interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingU.getPackageName(),
+ "GroupingU is in wrong package.");
- assertNotNull("Generated type for grouping-V wasn't generated.", groupingV);
- assertEquals("GroupingV interface generated more than one time.", 1, groupingVCounter);
- assertEquals("GroupingV is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingV.getPackageName());
+ assertNotNull(groupingV, "Generated type for grouping-V wasn't generated.");
+ assertEquals(1, groupingVCounter, "GroupingV interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingV.getPackageName(),
+ "GroupingV is in wrong package.");
- assertNotNull("Generated type for grouping-X wasn't generated.", groupingX);
- assertEquals("GroupingX interface generated more than one time.", 1, groupingXCounter);
- assertEquals("GroupingX is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingX.getPackageName());
+ assertNotNull(groupingX, "Generated type for grouping-X wasn't generated.");
+ assertEquals(1, groupingXCounter, "GroupingX interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingX.getPackageName(),
+ "GroupingX is in wrong package.");
containsInterface("GroupingV", groupingU);
containsInterface("GroupingX", groupingU);
}
@Test
- public void usesInCaseTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void usesInCaseTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/uses-of-grouping/uses-of-grouping-case.yang"));
GeneratedType groupingCaseTest = null;
int groupingCaseTestCounter = 0;
GeneratedType caseC = null;
int caseCCounter = 0;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("C")) {
caseC = genType;
}
}
- assertNotNull("Generated type for case C wasn't generated.", caseC);
- assertEquals("Case C interface generated more than one time.", 1, caseCCounter);
+ assertNotNull(caseC, "Generated type for case C wasn't generated.");
+ assertEquals(1, caseCCounter, "Case C interface generated more than one time.");
assertEquals(
- "Case C is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718.container.with.choicetest.choice.test",
- caseC.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718.container.with.choicetest.choice.test",
+ caseC.getPackageName(),
+ "Case C is in wrong package.");
- assertNotNull("Generated type for grouping-case-test wasn't generated.", groupingCaseTest);
- assertEquals("GroupingCaseTest interface generated more than one time.", 1, groupingCaseTestCounter);
- assertEquals("GroupingCaseTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718", groupingCaseTest.getPackageName());
+ assertNotNull(groupingCaseTest, "Generated type for grouping-case-test wasn't generated.");
+ assertEquals(1, groupingCaseTestCounter, "GroupingCaseTest interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718",
+ groupingCaseTest.getPackageName(), "GroupingCaseTest is in wrong package.");
containsInterface("GroupingCaseTest", caseC);
// FIXME: split this into getter/default/static asserts
assertEquals(4, caseC.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingCaseTest is incorrect", 2, groupingCaseTest.getMethodDefinitions()
- .size());
+ assertEquals(2, groupingCaseTest.getMethodDefinitions().size(),
+ "Number of method in GroupingCaseTest is incorrect");
containsMethods(groupingCaseTest.getMethodDefinitions(),
new NameTypePattern("getLeafGroupingCaseTest1", "String"),
new NameTypePattern("requireLeafGroupingCaseTest1", "String"));
}
@Test
- public void usesInContainerTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void usesInContainerTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/uses-of-grouping/uses-of-grouping-container.yang"));
int containerTestCount = 0;
GeneratedType containerTest = null;
GeneratedType groupingContainerTest = null;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingContainerTest")) {
groupingContainerTest = genType;
}
}
- assertNotNull("Generated type for grouping-container-test wasn't generated", groupingContainerTest);
- assertEquals("GroupingContainerTest interface - incorrect number of occurences", 1,
- groupingContainerTestCounter);
- assertEquals("GroupingContainerTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
- groupingContainerTest.getPackageName());
+ assertNotNull(groupingContainerTest, "Generated type for grouping-container-test wasn't generated");
+ assertEquals(1, groupingContainerTestCounter,
+ "GroupingContainerTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
+ groupingContainerTest.getPackageName(), "GroupingContainerTest isn't in correct package");
- assertNotNull("Generated type for container-test wasn't generated", containerTest);
- assertEquals("ContainerTest interface - incorrect number of occurences", 1, containerTestCount);
- assertEquals("ContainerTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718", containerTest.getPackageName());
+ assertNotNull(containerTest, "Generated type for container-test wasn't generated");
+ assertEquals(1, containerTestCount, "ContainerTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
+ containerTest.getPackageName(), "ContainerTest isn't in correct package");
containsInterface("GroupingContainerTest", containerTest);
- assertEquals("Number of method in GroupingContainerTestis incorrect", 4, groupingContainerTest
- .getMethodDefinitions().size());
+ assertEquals(4, groupingContainerTest.getMethodDefinitions().size(),
+ "Number of method in GroupingContainerTestis incorrect");
// FIXME: split this into getter/default/static asserts
assertEquals(6, containerTest.getMethodDefinitions().size());
}
@Test
- public void usesInGroupingTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void usesInGroupingTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/uses-of-grouping/uses-of-grouping-grouping.yang"));
int groupingTestCount = 0;
GeneratedType groupingTest = null;
GeneratedType groupingGroupingTest = null;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingGroupingTest")) {
groupingGroupingTest = genType;
}
}
- assertNotNull("Generated type for grouping-grouping-test wasn't generated", groupingGroupingTest);
- assertEquals("GroupingGroupingTest interface - incorrect number of occurences", 1, groupingGroupingTestCounter);
- assertEquals("GroupingGroupingTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718",
- groupingGroupingTest.getPackageName());
+ assertNotNull(groupingGroupingTest, "Generated type for grouping-grouping-test wasn't generated");
+ assertEquals(1, groupingGroupingTestCounter, "GroupingGroupingTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718",
+ groupingGroupingTest.getPackageName(), "GroupingGroupingTest isn't in correct package");
- assertNotNull("Generated type for grouping-test wasn't generated", groupingTest);
- assertEquals("GroupingTest interface - incorrect number of occurences", 1, groupingTestCount);
- assertEquals("GroupingTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718", groupingTest.getPackageName());
+ assertNotNull(groupingTest, "Generated type for grouping-test wasn't generated");
+ assertEquals(1, groupingTestCount, "GroupingTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718", groupingTest.getPackageName(),
+ "GroupingTest isn't in correct package");
containsInterface("GroupingGroupingTest", groupingTest);
- assertEquals("Number of method in GroupingGroupingTest is incorrect", 2, groupingGroupingTest
- .getMethodDefinitions().size());
- assertEquals("Number of method in GroupingTest is incorrect", 2, groupingTest.getMethodDefinitions().size());
+ assertEquals(2, groupingGroupingTest.getMethodDefinitions().size(),
+ "Number of method in GroupingGroupingTest is incorrect");
+ assertEquals(2, groupingTest.getMethodDefinitions().size(), "Number of method in GroupingTest is incorrect");
containsMethods(groupingGroupingTest.getMethodDefinitions(),
new NameTypePattern("getLeafGroupingGrouping", "String"),
}
@Test
- public void usesInListTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void usesInListTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/uses-of-grouping/uses-of-grouping-list.yang"));
int listTestCounter = 0;
GeneratedType containerGroupingListTest = null;
GeneratedType listGroupingListTest = null;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingListTest")) {
groupingListTest = genType;
}
}
- assertNotNull("Generated type for grouping-list-test wasn't generated", groupingListTest);
- assertEquals("GroupingListTest interface - incorrect number of occurences", 1, groupingListTestCounter);
- assertEquals("GroupingListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", groupingListTest.getPackageName());
-
- assertNotNull("Generated type for list-test wasn't generated", listTest);
- assertEquals("ListTest interface - incorrect number of occurences", 1, listTestCounter);
- assertEquals("ListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", listTest.getPackageName());
-
- assertNotNull("Generated type for container-grouping-list-test wasn't generated", containerGroupingListTest);
- assertEquals("ContainerGroupingListTest interface - incorrect number of occurences", 1,
- containerGroupingListTestCounter);
- assertEquals("ContainerGroupingListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
- containerGroupingListTest.getPackageName());
-
- assertNotNull("Generated type for list-grouping-list-test wasn't generated", listGroupingListTest);
- assertEquals("ListGroupingListTest interface - incorrect number of occurences", 1, listGroupingListTestCounter);
- assertEquals("ListGroupingListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
- listGroupingListTest.getPackageName());
+ assertNotNull(groupingListTest, "Generated type for grouping-list-test wasn't generated");
+ assertEquals(1, groupingListTestCounter, "GroupingListTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", groupingListTest.getPackageName(),
+ "GroupingListTest isn't in correct package");
+
+ assertNotNull(listTest, "Generated type for list-test wasn't generated");
+ assertEquals(1, listTestCounter, "ListTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", listTest.getPackageName(),
+ "ListTest isn't in correct package");
+
+ assertNotNull(containerGroupingListTest, "Generated type for container-grouping-list-test wasn't generated");
+ assertEquals(1, containerGroupingListTestCounter,
+ "ContainerGroupingListTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
+ containerGroupingListTest.getPackageName(), "ContainerGroupingListTest isn't in correct package");
+
+ assertNotNull(listGroupingListTest, "Generated type for list-grouping-list-test wasn't generated");
+ assertEquals(1, listGroupingListTestCounter, "ListGroupingListTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
+ listGroupingListTest.getPackageName(), "ListGroupingListTest isn't in correct package");
containsInterface("GroupingListTest", listTest);
- assertEquals("Number of method in GroupingListTest is incorrect", 8, groupingListTest.getMethodDefinitions()
- .size());
+ assertEquals(8, groupingListTest.getMethodDefinitions().size(),
+ "Number of method in GroupingListTest is incorrect");
// FIXME: split this into getter/default/static asserts
assertEquals(6, listTest.getMethodDefinitions().size());
// FIXME: split this into getter/default/static asserts
}
@Test
- public void usesInModulTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void usesInModulTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/uses-of-grouping/uses-of-grouping-modul.yang"));
int groupingModulTestCounter = 0;
GeneratedType groupingModulTest = null;
GeneratedType groupingUsesModulData = null;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingModulTest")) {
groupingModulTest = genType;
}
}
- assertNotNull("Generated type for grouping-list-test wasn't generated", groupingModulTest);
- assertEquals("GroupingModulTest interface - incorrect number of occurences", 1, groupingModulTestCounter);
- assertEquals("GroupingModulTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718", groupingModulTest.getPackageName());
+ assertNotNull(groupingModulTest, "Generated type for grouping-list-test wasn't generated");
+ assertEquals(1, groupingModulTestCounter, "GroupingModulTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
+ groupingModulTest.getPackageName(), "GroupingModulTest isn't in correct package");
- assertNotNull("Generated type for modul wasn't generated", groupingUsesModulData);
- assertEquals("GroupingUsesModulData interface - incorrect number of occurences", 1,
- groupingUsesModulDataCounter);
- assertEquals("GroupingUsesModulData isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
- groupingUsesModulData.getPackageName());
+ assertNotNull(groupingUsesModulData, "Generated type for modul wasn't generated");
+ assertEquals(1, groupingUsesModulDataCounter,
+ "GroupingUsesModulData interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
+ groupingUsesModulData.getPackageName(), "GroupingUsesModulData isn't in correct package");
containsInterface("GroupingModulTest", groupingUsesModulData);
- assertEquals("Number of method in GroupingUsesModulData is incorrect", 1, groupingUsesModulData
- .getMethodDefinitions().size());
- assertEquals("Number of method in GroupingModulTest is incorrect", 4, groupingModulTest.getMethodDefinitions()
- .size());
+ assertEquals(1, groupingUsesModulData.getMethodDefinitions().size(),
+ "Number of method in GroupingUsesModulData is incorrect");
+ assertEquals(4, groupingModulTest.getMethodDefinitions().size(),
+ "Number of method in GroupingModulTest is incorrect");
containsMethods(groupingModulTest.getMethodDefinitions(),
new NameTypePattern("getLeafGroupingModulTest", "String"),
}
@Test
- public void usesInRpcTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ void usesInRpcTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
"/uses-of-grouping/uses-of-grouping-rpc.yang"));
int rpcTestInputCounter = 0;
GeneratedType groupingRpcOutputTest = null;
GeneratedType containerGroupingRpcInputTest = null;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("RpcTestInput")) {
rpcTestInput = genType;
}
}
- assertNotNull("Generated type for RPC test input was not generated", rpcTestInput);
- assertEquals("RpcTestInput interface - incorrect number of occurences", 1, rpcTestInputCounter);
- assertEquals("RpcTestInput is not in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName());
-
- assertNotNull("Generated type for RPC test output was not generated", rpcTestOutput);
- assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, rpcTestOutputCounter);
- assertEquals("RpcTestOutput is not in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName());
-
- assertNotNull("Generated type for grouping-rpc-input-test was not generated", groupingRpcInputTest);
- assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcInputTestCounter);
- assertEquals("GroupingRpcInputTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcInputTest.getPackageName());
-
- assertNotNull("Generated type for grouping-rpc-output-test was not generated", groupingRpcOutputTest);
- assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcOutputTestCounter);
- assertEquals("GroupingRpcOutputTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcOutputTest.getPackageName());
-
- assertNotNull("Generated type for container-grouping-rpc-input-test wasn't generated",
- containerGroupingRpcInputTest);
- assertEquals("ContainerGroupingRpcInputTest interface - incorrect number of occurences", 1,
- containerGroupingRpcInputTestCounter);
- assertEquals("ContainerGroupingRpcInputTest is not in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
- containerGroupingRpcInputTest.getPackageName());
+ assertNotNull(rpcTestInput, "Generated type for RPC test input was not generated");
+ assertEquals(1, rpcTestInputCounter, "RpcTestInput interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName(),
+ "RpcTestInput is not in correct package");
+
+ assertNotNull(rpcTestOutput, "Generated type for RPC test output was not generated");
+ assertEquals(1, rpcTestOutputCounter, "RpcTestOutput interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName(),
+ "RpcTestOutput is not in correct package");
+
+ assertNotNull(groupingRpcInputTest, "Generated type for grouping-rpc-input-test was not generated");
+ assertEquals(1, groupingRpcInputTestCounter, "RpcTestOutput interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718",
+ groupingRpcInputTest.getPackageName(), "GroupingRpcInputTest isn't in correct package");
+
+ assertNotNull(groupingRpcOutputTest, "Generated type for grouping-rpc-output-test was not generated");
+ assertEquals(1, groupingRpcOutputTestCounter, "RpcTestOutput interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718",
+ groupingRpcOutputTest.getPackageName(), "GroupingRpcOutputTest isn't in correct package");
+
+ assertNotNull(containerGroupingRpcInputTest,
+ "Generated type for container-grouping-rpc-input-test wasn't generated");
+ assertEquals(1, containerGroupingRpcInputTestCounter,
+ "ContainerGroupingRpcInputTest interface - incorrect number of occurences");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
+ containerGroupingRpcInputTest.getPackageName(), "ContainerGroupingRpcInputTest is not in correct package");
containsInterface("GroupingRpcInputTest", rpcTestInput);
containsInterface("GroupingRpcOutputTest", rpcTestOutput);
assertEquals(4, rpcTestInput.getMethodDefinitions().size());
// FIXME: split this into getter/default/static asserts
assertEquals(4, rpcTestOutput.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingRpcInputTest is incorrect", 4, groupingRpcInputTest
- .getMethodDefinitions().size());
- assertEquals("Number of method in GroupingRpcOutputTest is incorrect", 2, groupingRpcOutputTest
- .getMethodDefinitions().size());
+ assertEquals(4, groupingRpcInputTest.getMethodDefinitions().size(),
+ "Number of method in GroupingRpcInputTest is incorrect");
+ assertEquals(2, groupingRpcOutputTest.getMethodDefinitions().size(),
+ "Number of method in GroupingRpcOutputTest is incorrect");
// FIXME: split this into getter/default/static asserts
assertEquals(6, containerGroupingRpcInputTest.getMethodDefinitions().size());
}
@Test
- public void usesInAugmentTest() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+ void usesInAugmentTest() {
+ final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-augment.yang"));
GeneratedType containerAugment1 = null;
int containerAugment1Counter = 0;
int groupingAugmentTestCounter = 0;
- for (GeneratedType genType : genTypes) {
+ for (var genType : genTypes) {
if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("ContainerAugment1")) {
containerAugment1 = genType;
}
}
- assertNotNull("Generated type for augment /container-augment wasn't generated.", containerAugment1);
- assertEquals("ContainerAugment1 interface generated more than one time.", 1, containerAugment1Counter);
- assertEquals("ContainerAugment1 is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718", containerAugment1.getPackageName());
+ assertNotNull(containerAugment1, "Generated type for augment /container-augment wasn't generated.");
+ assertEquals(1, containerAugment1Counter, "ContainerAugment1 interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
+ containerAugment1.getPackageName(), "ContainerAugment1 is in wrong package.");
- assertNotNull("Generated type for grouping-augment-test wasn't generated.", groupingAugmentTest);
- assertEquals("GroupingAugmentTest interface generated more than one time.", 1, groupingAugmentTestCounter);
- assertEquals("groupingAugmentTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
- groupingAugmentTest.getPackageName());
+ assertNotNull(groupingAugmentTest, "Generated type for grouping-augment-test wasn't generated.");
+ assertEquals(1, groupingAugmentTestCounter, "GroupingAugmentTest interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
+ groupingAugmentTest.getPackageName(), "groupingAugmentTest is in wrong package.");
containsInterface("GroupingAugmentTest", containerAugment1);
assertEquals(4, containerAugment1.getMethodDefinitions().size());
// FIXME: split this into getter/default/static asserts
assertEquals(4, containerAugment1.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingCaseTest is incorrect", 2, groupingAugmentTest.getMethodDefinitions()
- .size());
+ assertEquals(2, groupingAugmentTest.getMethodDefinitions().size(),
+ "Number of method in GroupingCaseTest is incorrect");
containsMethods(groupingAugmentTest.getMethodDefinitions(),
new NameTypePattern("getLeafGroupingAugmentTest", "String"),
}
@Test
- public void usesInNotification() {
- final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+ void usesInNotification() {
+ final var genTypes = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-notification.yang"));
GeneratedType notificationTest = null;
int groupingNotificationTestCounter = 0;
int containerGroupingNotificationTestCounter = 0;
- for (GeneratedType type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = type;
- if (genType.getName().equals("NotificationTest")) {
- notificationTest = genType;
+ for (var type : genTypes) {
+ if (!(type instanceof GeneratedTransferObject)) {
+ if (type.getName().equals("NotificationTest")) {
+ notificationTest = type;
notificationTestCounter++;
- } else if (genType.getName().equals("GroupingNotificationTest")) {
- groupingNotificationTest = genType;
+ } else if (type.getName().equals("GroupingNotificationTest")) {
+ groupingNotificationTest = type;
groupingNotificationTestCounter++;
- } else if (genType.getName().equals("ContainerGroupingNotificationTest")) {
- containerGroupingNotificationTest = genType;
+ } else if (type.getName().equals("ContainerGroupingNotificationTest")) {
+ containerGroupingNotificationTest = type;
containerGroupingNotificationTestCounter++;
}
}
}
- assertNotNull("Generated type for notification-test wasn't generated.", notificationTest);
- assertEquals("NotificationTest interface generated more than one time.", 1, notificationTestCounter);
- assertEquals("NotificationTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
- notificationTest.getPackageName());
-
- assertNotNull("Generated type for grouping-notification-test wasn't generated.", groupingNotificationTest);
- assertEquals("GroupingNotificationTest interface generated more than one time.", 1,
- groupingNotificationTestCounter);
- assertEquals("groupingNotificationTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
- groupingNotificationTest.getPackageName());
-
- assertNotNull("Generated type for container-grouping-notification-test wasn't generated.",
- containerGroupingNotificationTest);
- assertEquals("ContainerGroupingNotificationTest interface generated more than one time.", 1,
- containerGroupingNotificationTestCounter);
- assertEquals("ContainerGroupingNotificationTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718.grouping.notification.test",
- containerGroupingNotificationTest.getPackageName());
+ assertNotNull(notificationTest, "Generated type for notification-test wasn't generated.");
+ assertEquals(1, notificationTestCounter, "NotificationTest interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
+ notificationTest.getPackageName(), "NotificationTest is in wrong package.");
+
+ assertNotNull(groupingNotificationTest, "Generated type for grouping-notification-test wasn't generated.");
+ assertEquals(1, groupingNotificationTestCounter,
+ "GroupingNotificationTest interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
+ groupingNotificationTest.getPackageName(), "groupingNotificationTest is in wrong package.");
+
+ assertNotNull(containerGroupingNotificationTest,
+ "Generated type for container-grouping-notification-test wasn't generated.");
+ assertEquals(1, containerGroupingNotificationTestCounter,
+ "ContainerGroupingNotificationTest interface generated more than one time.");
+ assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718.grouping.notification.test",
+ containerGroupingNotificationTest.getPackageName(),
+ "ContainerGroupingNotificationTest is in wrong package.");
containsInterface("GroupingNotificationTest", notificationTest);
// FIXME: split this into getter/default/static asserts
assertEquals(6, notificationTest.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingNotificationTest is incorrect", 4, groupingNotificationTest
- .getMethodDefinitions().size());
+ assertEquals(4, groupingNotificationTest.getMethodDefinitions().size(),
+ "Number of method in GroupingNotificationTest is incorrect");
// FIXME: split this into getter/default/static asserts
assertEquals(6, containerGroupingNotificationTest.getMethodDefinitions().size());
new NameTypePattern("getLeafContainerGroupingNotificationTest", "Uint32"),
new NameTypePattern("requireLeafContainerGroupingNotificationTest", "Uint32"));
}
-
}
*/
package org.opendaylight.yangtools.binding.generator.impl.reactor;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doReturn;
import java.util.List;
import java.util.Optional;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
import org.opendaylight.yangtools.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.yangtools.binding.model.ri.generated.type.builder.CodegenGeneratedTOBuilder;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class GeneratorTest {
+@ExtendWith(MockitoExtension.class)
+class GeneratorTest {
@Mock
- public TypeDefinition<?> typedef;
+ private TypeDefinition<?> typedef;
- public final GeneratedTOBuilder builder =
+ private final GeneratedTOBuilder builder =
new CodegenGeneratedTOBuilder(JavaTypeName.create("test.package", "TestBuilder"));
@Test
- public void testAddUnits() {
+ void testAddUnits() {
doReturn(Optional.of("125")).when(typedef).getUnits();
Generator.addUnits(builder, typedef);
- final GeneratedTransferObject genTO = builder.build();
+ final var genTO = builder.build();
assertEquals(1, genTO.getConstantDefinitions().size());
assertEquals("_UNITS", genTO.getConstantDefinitions().get(0).getName());
assertEquals(genTO.getConstantDefinitions().get(0).getValue(), "\"125\"");
}
@Test
- public void testAddUnitsNonExistent() {
+ void testAddUnitsNonExistent() {
doReturn(Optional.empty()).when(typedef).getUnits();
Generator.addUnits(builder, typedef);
- GeneratedTransferObject genTO = builder.build();
+ var genTO = builder.build();
assertEquals(List.of(), genTO.getConstantDefinitions());
}
@Test
- public void testAddUnitsEmpty() {
+ void testAddUnitsEmpty() {
doReturn(Optional.of("")).when(typedef).getUnits();
Generator.addUnits(builder, typedef);
- GeneratedTransferObject genTO = builder.build();
+ var genTO = builder.build();
assertEquals(List.of(), genTO.getConstantDefinitions());
}
}