*/
package org.opendaylight.yangtools.sal.binding.yang.types;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
*/
package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
*/
package org.opendaylight.yangtools.sal.binding.yang.types;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
*/
package org.mockito.configuration;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.Closeable;
import java.io.IOException;
import org.mockito.Mockito;
public class DefaultAnswerTest {
-
- @Test
- public void testAnswering() throws IOException {
- Closeable mock = Mockito.mock(Closeable.class);
- try {
- mock.close();
- fail();
- } catch (UnstubbedMethodException e) {
- assertEquals("closeable.close(); was not stubbed", e.getMessage());
- }
- }
-
-
-
+ @Test
+ public void testAnswering() throws IOException {
+ Closeable mock = Mockito.mock(Closeable.class);
+ try {
+ mock.close();
+ fail();
+ } catch (UnstubbedMethodException e) {
+ assertEquals("closeable.close(); was not stubbed", e.getMessage());
+ }
+ }
}
package org.opendaylight.yangtools.util.concurrent;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.opendaylight.yangtools.util.concurrent.AsyncNotifyingListeningExecutorServiceTest.testListenerCallback;
+import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_CALLABLE;
+import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE;
+import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE_WITH_RESULT;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-import static org.opendaylight.yangtools.util.concurrent.AsyncNotifyingListeningExecutorServiceTest.testListenerCallback;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.Invoker;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_CALLABLE;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE_WITH_RESULT;
+import org.opendaylight.yangtools.util.concurrent.CommonTestUtils.Invoker;
/**
* Unit tests for DeadlockDetectingListeningExecutorService.
static final InitialInvoker SUBMIT = new InitialInvoker() {
@Override
- public void invokeExecutor( ListeningExecutorService executor, Runnable task ) {
+ public void invokeExecutor( final ListeningExecutorService executor, final Runnable task ) {
executor.submit( task );
}
};
static final InitialInvoker EXECUTE = new InitialInvoker() {
@Override
- public void invokeExecutor( ListeningExecutorService executor, Runnable task ) {
+ public void invokeExecutor( final ListeningExecutorService executor, final Runnable task ) {
executor.execute( task );
}
};
public static Function<Void, Exception> DEADLOCK_EXECUTOR_FUNCTION = new Function<Void, Exception>() {
@Override
- public Exception apply( Void notUsed ) {
+ public Exception apply( final Void notUsed ) {
return new TestDeadlockException();
}
};
testNonBlockingSubmitOnExecutorThread( EXECUTE, SUBMIT_CALLABLE );
}
- void testNonBlockingSubmitOnExecutorThread( InitialInvoker initialInvoker,
- final Invoker invoker ) throws Throwable {
+ void testNonBlockingSubmitOnExecutorThread( final InitialInvoker initialInvoker,
+ final Invoker invoker ) throws Throwable {
final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
final CountDownLatch futureCompletedLatch = new CountDownLatch( 1 );
Futures.addCallback( invoker.invokeExecutor( executor, null ), new FutureCallback() {
@Override
- public void onSuccess( Object result ) {
+ public void onSuccess( final Object result ) {
futureCompletedLatch.countDown();
}
@Override
- public void onFailure( Throwable t ) {
+ public void onFailure( final Throwable t ) {
caughtEx.set( t );
futureCompletedLatch.countDown();
}
initialInvoker.invokeExecutor( executor, task );
assertTrue( "Task did not complete - executor likely deadlocked",
- futureCompletedLatch.await( 5, TimeUnit.SECONDS ) );
+ futureCompletedLatch.await( 5, TimeUnit.SECONDS ) );
if( caughtEx.get() != null ) {
throw caughtEx.get();
testBlockingSubmitOnExecutorThread( EXECUTE, SUBMIT_CALLABLE );
}
- void testBlockingSubmitOnExecutorThread( InitialInvoker initialInvoker,
- final Invoker invoker ) throws Exception {
+ void testBlockingSubmitOnExecutorThread( final InitialInvoker initialInvoker,
+ final Invoker invoker ) throws Exception {
final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch( 1 );
initialInvoker.invokeExecutor( executor, task );
assertTrue( "Task did not complete - executor likely deadlocked",
- latch.await( 5, TimeUnit.SECONDS ) );
+ latch.await( 5, TimeUnit.SECONDS ) );
assertNotNull( "Expected exception thrown", caughtEx.get() );
assertEquals( "Caught exception type", TestDeadlockException.class, caughtEx.get().getClass() );
executor = new DeadlockDetectingListeningExecutorService(
Executors.newSingleThreadExecutor(
new ThreadFactoryBuilder().setNameFormat( "SingleThread" ).build() ),
- DEADLOCK_EXECUTOR_FUNCTION, listenerExecutor );
+ DEADLOCK_EXECUTOR_FUNCTION, listenerExecutor );
try {
testListenerCallback( executor, SUBMIT_CALLABLE, listenerThreadPrefix );
package org.opendaylight.yangtools.it.yang.runtime.tests;
-import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import com.google.common.base.Optional;
+
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.base.Optional;
-
public class RuntimeCodecAugmentationWithGroupingsAndCasesTest {
private static final InstanceIdentifier<ExtWithGroupingAugmentations> GROUPING_AUGMENTATIONS_PATH = InstanceIdentifier
public void testSerialization() {
ExtWithGroupingAugmentations caseData = new ExtWithGroupingAugmentationsBuilder() //
- .setGroupingData(new GroupingDataBuilder() //
- .addAugmentation(InUsesAugment.class, new InUsesAugmentBuilder() //
- .setExtAumentation("InUses") //
- .build()) //
- .build()) //
- .build();
+ .setGroupingData(new GroupingDataBuilder() //
+ .addAugmentation(InUsesAugment.class, new InUsesAugmentBuilder() //
+ .setExtAumentation("InUses") //
+ .build()) //
+ .build()) //
+ .build();
Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> result = mappingService
.toDataDom(new SimpleEntry(GROUPING_AUGMENTATIONS_PATH, caseData));
package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924;
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
public class HostBuilderTest {
@Test
public void testGetDefaultInstanceIpv4() throws Exception {
Host host = HostBuilder.getDefaultInstance("127.0.0.1");
- Assert.assertEquals(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))), host);
+ assertEquals(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))), host);
}
@Test
testIpv6("2001:db8:85a3::8a2e:370:7334");
}
- private void testIpv6(String ivp6string) {
+ private void testIpv6(final String ivp6string) {
Host host = HostBuilder.getDefaultInstance(ivp6string);
- Assert.assertEquals(new Host(new IpAddress(new Ipv6Address(ivp6string))), host);
+ assertEquals(new Host(new IpAddress(new Ipv6Address(ivp6string))), host);
}
@Test
public void testGetDefaultInstanceDomain() throws Exception {
Host host = HostBuilder.getDefaultInstance("localhost");
- Assert.assertEquals(new Host(new DomainName("localhost")), host);
+ assertEquals(new Host(new DomainName("localhost")), host);
}
}
\ No newline at end of file
*/
package org.opendaylight.yangtools.restconf.utils;
-import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import java.util.AbstractMap.SimpleEntry;
*/
package org.opendaylight.yangtools.restconf.utils;
-import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.InputStream;
*/
package org.opendaylight.yangtools.restconf.utils;
-import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import com.google.common.collect.ImmutableList;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import javax.activation.UnsupportedDataTypeException;
import javax.xml.parsers.DocumentBuilder;
import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl;
import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* returns <code>null</code>
*/
public static CompositeNode rpcReplyToDomNodes(final Document document, final QName rpcName,
- final SchemaContext context) {
+ final SchemaContext context) {
Preconditions.checkNotNull(document);
Preconditions.checkNotNull(rpcName);
Preconditions.checkNotNull(context);
Optional<RpcDefinition> rpcDefinition = findRpc(rpcName, context);
if (rpcDefinition.isPresent()) {
- RpcDefinition rpc = rpcDefinition.get();
+ RpcDefinition rpc = rpcDefinition.get();
final Collection<DataSchemaNode> outputNode = rpc.getOutput().getChildNodes();
final Element rpcReplyElement = document.getDocumentElement();
if (RPC_REPLY_QNAME.equals(partialQName)) {
final List<Node<?>> domNodes = toDomNodes(rpcReplyElement, Optional.fromNullable(outputNode), context);
List<Node<?>> rpcOutNodes = Collections.<Node<?>>singletonList(ImmutableCompositeNode.create(
- rpc.getOutput().getQName(), domNodes));
+ rpc.getOutput().getQName(), domNodes));
return ImmutableCompositeNode.create(rpcName, rpcOutNodes);
}
}
* @param context Schema Context
* @return Rpc Definition if is present within given Schema Context, otherwise returns Optional.absent().
*/
- private static Optional<RpcDefinition> findRpc(QName rpc, SchemaContext context) {
+ private static Optional<RpcDefinition> findRpc(final QName rpc, final SchemaContext context) {
Preconditions.checkNotNull(rpc);
Preconditions.checkNotNull(context);
for (final RpcDefinition rpcDefinition : context.getOperations()) {
*/
package org.opendaylight.yangtools.yang.data.codec.xml.test;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
@Before
public void setup() throws Exception {
final List<InputStream> modelsToParse = Collections
- .singletonList(getClass().getResourceAsStream(RES_SCHEMA_DIR + "/rpc-test-model.yang"));
+ .singletonList(getClass().getResourceAsStream(RES_SCHEMA_DIR + "/rpc-test-model.yang"));
assertNotNull(modelsToParse);
assertNotNull(modelsToParse.get(0));
assertNotNull(testPayload2);
}
- private static Document readXmlToDocument(InputStream xmlContent) throws SAXException, IOException {
+ private static Document readXmlToDocument(final InputStream xmlContent) throws SAXException, IOException {
DocumentBuilder dBuilder;
try {
dBuilder = BUILDER_FACTORY.newDocumentBuilder();
@Test
public void test() {
final CompositeNode rockNode = XmlDocumentUtils
- .rpcReplyToDomNodes(testPayload1, ROCK_THE_HOUSE_QNAME, schemaContext);
+ .rpcReplyToDomNodes(testPayload1, ROCK_THE_HOUSE_QNAME, schemaContext);
assertNotNull(rockNode);
final String namespace = "org:opendaylight:rpc-reply:test:ns:yang";
assertNotNull(output);
final SimpleNode<?> zipCode = output.getFirstSimpleByName(
- QName.create(namespace, revision, "zip-code"));
+ QName.create(namespace, revision, "zip-code"));
assertNotNull(zipCode);
final CompositeNode activNode = XmlDocumentUtils
- .rpcReplyToDomNodes(testPayload2, ACTIV_SW_IMAGE_QNAME, schemaContext);
+ .rpcReplyToDomNodes(testPayload2, ACTIV_SW_IMAGE_QNAME, schemaContext);
assertNotNull(activNode);
output = activNode.getFirstCompositeByName(RPC_OUTPUT_QNAME);
assertNotNull(output);
final CompositeNode imgProps = output
- .getFirstCompositeByName(QName.create(namespace, revision, "image-properties"));
+ .getFirstCompositeByName(QName.create(namespace, revision, "image-properties"));
assertNotNull(imgProps);
final CompositeNode imgProperty = imgProps
- .getFirstCompositeByName(QName.create(namespace, revision, "image-property"));
+ .getFirstCompositeByName(QName.create(namespace, revision, "image-property"));
assertNotNull(imgProperty);
final SimpleNode<?> imgId = imgProperty
- .getFirstSimpleByName(QName.create(namespace, revision, "image-id"));
+ .getFirstSimpleByName(QName.create(namespace, revision, "image-id"));
assertNotNull(imgId);
}
}
*/
package org.opendaylight.yangtools.yang.data.impl;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
*/
package org.opendaylight.yangtools.yang.data.impl;
+import static org.junit.Assert.assertSame;
+
import java.net.URI;
import java.util.Date;
-import junit.framework.Assert;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
Node<?> mutableEquivalent = nodeModificationBuilder.getMutableEquivalent(topologies);
CompositeNode topologiesMutable = rootMutable.getCompositesByName("topologies").iterator().next();
- Assert.assertSame(topologiesMutable, mutableEquivalent);
+ assertSame(topologiesMutable, mutableEquivalent);
}
/**
package org.opendaylight.yangtools.yang.data.impl.codec.xml;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.google.common.io.ByteSource;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+
import javax.activation.UnsupportedDataTypeException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.Assert;
+
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Before;
import org.junit.Test;
final CompositeNode node = inputXmlToCompositeNode(input);
final SimpleNode<?> refParsed = node.getSimpleNodesByName("ref").iterator().next();
- Assert.assertEquals(YangInstanceIdentifier.class, refParsed.getValue().getClass());
+ assertEquals(YangInstanceIdentifier.class, refParsed.getValue().getClass());
final Document serializedDocument = inputCompositeNodeToXml(node);
XMLUnit.compareXML(inputDocument, serializedDocument);
package org.opendaylight.yangtools.yang.data.impl.codec.xml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
+
import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.util.AbstractMap;
import java.util.Map;
+
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
-import junit.framework.Assert;
+
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
final String xmlAsString = new String(out.toByteArray());
final Map<String, String> mappedPrefixes = mapPrefixed(randomPrefix.getPrefixes());
- Assert.assertEquals(2, mappedPrefixes.size());
+ assertEquals(2, mappedPrefixes.size());
final String randomPrefixValue = mappedPrefixes.get("namespace2");
final String expectedXmlAsString = "<element xmlns:prefix=\"namespace\" prefix:attr=\"value\" xmlns:" + randomPrefixValue + "=\"namespace2\" " + randomPrefixValue + ":attr=\"value\"></element>";
final Diff diff = XMLUnit.compareXML(control, test);
final boolean identical = diff.identical();
- Assert.assertTrue("Xml differs: " + diff.toString(), identical);
+ assertTrue("Xml differs: " + diff.toString(), identical);
}
private Map<String, String> mapPrefixed(final Iterable<Map.Entry<URI, String>> prefixes) {
Collections.singletonList(doc.getDocumentElement()), containerNode);
if (expectedNode != null) {
- junit.framework.Assert.assertEquals(expectedNode, built);
+ org.junit.Assert.assertEquals(expectedNode, built);
}
logger.info("{}", built);
package org.opendaylight.yangtools.yang.data.impl.schema.tree;
+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.Assert.fail;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
import com.google.common.base.Optional;
-import junit.framework.Assert;
+
+import java.util.Map;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.*;
-
public class TreeNodeUtilsTest {
private static final Logger LOG = LoggerFactory.getLogger(TreeNodeUtilsTest.class);
.withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME)) //
.withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME)) //
.build()) //
- .build();
+ .build();
private SchemaContext schemaContext;
private RootModificationApplyOperation rootOper;
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
.withChild(
mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
- .withChild(BAR_NODE).build()).build();
+ .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+ .withChild(BAR_NODE).build()).build();
}
private static <T> T assertPresentAndType(final Optional<?> potential, final Class<T> type) {
.nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3) //
.build();
Optional<TreeNode> node = TreeNodeUtils.findNode(rootNode, outerList1InvalidPath);
- Assert.assertFalse(node.isPresent());
+ assertFalse(node.isPresent());
}
@Test
} catch (IllegalArgumentException e) {
fail("Illegal argument exception was thrown and should not have been" + e.getMessage());
}
- Assert.assertNotNull(foundNode);
+ assertNotNull(foundNode);
}
@Test
Optional<TreeNode> expectedNode = TreeNodeUtils.findNode(rootNode, TWO_TWO_PATH);
assertPresentAndType(expectedNode, TreeNode.class);
Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = TreeNodeUtils.findClosest(rootNode, TWO_TWO_PATH);
- Assert.assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
+ assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
}
@Test
Optional<TreeNode> expectedNode = TreeNodeUtils.findNode(rootNode, outerListInnerListPath);
assertPresentAndType(expectedNode, TreeNode.class);
Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = TreeNodeUtils.findClosest(rootNode, twoTwoInvalidPath);
- Assert.assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
+ assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
}
@Test
TreeNode rootNode = inMemoryDataTreeSnapshot.getRootNode();
Optional<TreeNode> node = TreeNodeUtils.getChild(Optional.fromNullable(rootNode),
TestModel.OUTER_LIST_PATH.getLastPathArgument());
- Assert.assertFalse(node.isPresent());
+ assertFalse(node.isPresent());
}
}
*/
package org.opendaylight.yangtools.yang.data.operations;
+import static org.junit.Assert.assertNull;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-
@RunWith(Parameterized.class)
public class YangDataOperationsTest {
@Parameterized.Parameters()
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
- // Container
- { "/containerTest_createContainer" },
- { "/containerTest_deleteContainer" },
- { "/containerTest_innerContainerContainer" },
- { "/containerTest_innerLeavesBaseOperationsContainer" },
- { "/containerTest_noneContainer" },
- { "/containerTest_removeContainer"},
- { "/containerTest_replaceContainer"},
- { "/containerTest_choiceActualModificationSameCase"},
- { "/containerTest_choiceActualModificationDifferentCases"},
- { "/containerTest_choiceActualOneCaseModificationOtherCase"},
-// LeafList
- { "/leafListTest" },
- // List
- { "/listTest" },
- // Additional
- {"/none_NoChange"},
- {"/listTest_alterInnerValue"}
+ // Container
+ { "/containerTest_createContainer" },
+ { "/containerTest_deleteContainer" },
+ { "/containerTest_innerContainerContainer" },
+ { "/containerTest_innerLeavesBaseOperationsContainer" },
+ { "/containerTest_noneContainer" },
+ { "/containerTest_removeContainer"},
+ { "/containerTest_replaceContainer"},
+ { "/containerTest_choiceActualModificationSameCase"},
+ { "/containerTest_choiceActualModificationDifferentCases"},
+ { "/containerTest_choiceActualOneCaseModificationOtherCase"},
+ // LeafList
+ { "/leafListTest" },
+ // List
+ { "/listTest" },
+ // Additional
+ {"/none_NoChange"},
+ {"/listTest_alterInnerValue"}
});
}
- public YangDataOperationsTest(String testDir) throws Exception {
+ public YangDataOperationsTest(final String testDir) throws Exception {
SchemaContext schema = parseTestSchema();
containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
this.testDirName = testDir;
if (result.isPresent()) {
verifyModificationResult(result, expectedResult);
} else {
- junit.framework.Assert.assertNull("Result of modification is empty node, result xml should not be present "
+ assertNull("Result of modification is empty node, result xml should not be present "
+ expectedResultXmlPath, getClass().getResourceAsStream(expectedResultXmlPath));
}
}
- private ModifyAction loadModifyAction(String path) throws Exception {
+ private ModifyAction loadModifyAction(final String path) throws Exception {
URL resource = getClass().getResource(path);
if (resource == null) {
return ModifyAction.MERGE;
return ModifyAction.fromXmlValue(Files.toString(new File(resource.toURI()), Charsets.UTF_8).trim());
}
- private void verifyModificationResult(Optional<ContainerNode> result, Optional<ContainerNode> expectedResult)
+ private void verifyModificationResult(final Optional<ContainerNode> result, final Optional<ContainerNode> expectedResult)
throws UnsupportedDataTypeException {
Assert.assertEquals(
String.format(
toString(toDom(expectedResult.get()))), expectedResult.get(), result.get());
}
- private Element toDom(ContainerNode container) {
+ private Element toDom(final ContainerNode container) {
Iterable<Element> a =
DomFromNormalizedNodeSerializerFactory.getInstance(newDocument(), DomUtils.defaultValueCodecProvider())
.getContainerNodeSerializer().serialize(containerNode, container);
}
}
- private Optional<ContainerNode> loadXmlToCompositeNode(String xmlPath) throws IOException, SAXException {
+ private Optional<ContainerNode> loadXmlToCompositeNode(final String xmlPath) throws IOException, SAXException {
InputStream resourceAsStream = getClass().getResourceAsStream(xmlPath);
if (resourceAsStream == null) {
return Optional.absent();
return Lists.newArrayList(Collections2.transform(Lists.newArrayList("/schemas/test.yang"),
new Function<String, InputStream>() {
- @Override
- public InputStream apply(String input) {
- InputStream resourceAsStream = getClass().getResourceAsStream(input);
- Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
- return resourceAsStream;
- }
- }));
+ @Override
+ public InputStream apply(final String input) {
+ InputStream resourceAsStream = getClass().getResourceAsStream(input);
+ Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
+ return resourceAsStream;
+ }
+ }));
}
- DataSchemaNode getSchemaNode(SchemaContext context, String moduleName, String childNodeName) {
+ DataSchemaNode getSchemaNode(final SchemaContext context, final String moduleName, final String childNodeName) {
for (Module module : context.getModules()) {
if (module.getName().equals(moduleName)) {
for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
- if (dataSchemaNode.getQName().getLocalName().equals(childNodeName))
+ if (dataSchemaNode.getQName().getLocalName().equals(childNodeName)) {
return dataSchemaNode;
+ }
}
}
}
BUILDERFACTORY = factory;
}
- private Document readXmlToDocument(InputStream xmlContent) throws IOException, SAXException {
+ private Document readXmlToDocument(final InputStream xmlContent) throws IOException, SAXException {
DocumentBuilder dBuilder;
try {
dBuilder = BUILDERFACTORY.newDocumentBuilder();
return doc;
}
- public static String toString(Element xml) {
+ public static String toString(final Element xml) {
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
*/
package org.opendaylight.yangtools.yang2sources.plugin.it;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
import com.google.common.base.Joiner;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.junit.Test;
+ "files marked as resources: META-INF/yang");
v.verifyTextInLog(
Joiner.on(File.separator).join(
- Arrays.asList("target", "generated-sources", "spi"))
+ Arrays.asList("target", "generated-sources", "spi"))
- + " marked as resources for generator: org.opendaylight.yangtools.yang2sources.spi.CodeGeneratorTestImpl");
+ + " marked as resources for generator: org.opendaylight.yangtools.yang2sources.spi.CodeGeneratorTestImpl");
}
@Test
v.verifyTextInLog("[WARNING] Naming conflict for type 'org.opendaylight.yang.gen.v1.urn.yang.test.rev140303.NetworkTopologyRef': file with same name already exists and will not be generated.");
}
- static void verifyCorrectLog(Verifier v) throws VerificationException {
+ static void verifyCorrectLog(final Verifier v) throws VerificationException {
v.verifyErrorFreeLog();
v.verifyTextInLog("[INFO] yang-to-sources: YANG files parsed from");
v.verifyTextInLog("[INFO] yang-to-sources: Code generator instantiated from org.opendaylight.yangtools.yang2sources.spi.CodeGeneratorTestImpl");
v.verifyTextInLog("[INFO] yang-to-sources: No input files found");
}
- static void assertVerificationException(VerificationException e,
- String string) {
+ static void assertVerificationException(final VerificationException e,
+ final String string) {
assertThat(e.getMessage(), containsString(string));
}
- static Verifier setUp(String project, boolean ignoreF)
+ static Verifier setUp(final String project, final boolean ignoreF)
throws VerificationException, URISyntaxException {
final URL path = YangToSourcesPluginTestIT.class.getResource("/"
+ project + "pom.xml");
File parent = new File(path.toURI());
Verifier verifier = new Verifier(parent.getParent());
- if (ignoreF)
+ if (ignoreF) {
verifier.addCliOption("-fn");
+ }
verifier.setMavenDebug(true);
verifier.executeGoal("generate-sources");
return verifier;
Properties sp = new Properties();
try (InputStream is = new FileInputStream(v1.getBasedir() + "/it-project.properties")) {
- sp.load(is);
+ sp.load(is);
}
String buildDir = sp.getProperty("target.dir");
sp = new Properties();
try (InputStream is = new FileInputStream(v2.getBasedir() + "/it-project.properties")) {
- sp.load(is);
+ sp.load(is);
}
buildDir = sp.getProperty("target.dir");
*/
package org.opendaylight.yangtools.yang2sources.plugin;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import com.google.common.collect.Lists;
import java.io.File;
import java.io.IOException;
import org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.YangProvider;
import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
-import com.google.common.collect.Lists;
-
public class GenerateSourcesTest {
private String yang;
@Test
public void test() throws Exception {
mojo.execute();
- assertThat(GeneratorMock.called, is(1));
- assertThat(GeneratorMock.outputDir, is(outDir));
- assertThat(GeneratorMock.project, is(project));
+ assertEquals(1, GeneratorMock.called);
+ assertEquals(outDir, GeneratorMock.outputDir);
+ assertEquals(project, GeneratorMock.project);
assertNotNull(GeneratorMock.log);
assertTrue(GeneratorMock.additionalCfg.isEmpty());
assertThat(GeneratorMock.resourceBaseDir.toString(), containsString("target" + File.separator
private static MavenProject project;
@Override
- public Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules)
+ public Collection<File> generateSources(final SchemaContext context, final File outputBaseDir, final Set<Module> currentModules)
throws IOException {
called++;
outputDir = outputBaseDir;
}
@Override
- public void setLog(Log log) {
+ public void setLog(final Log log) {
GeneratorMock.log = log;
}
@Override
- public void setAdditionalConfig(Map<String, String> additionalConfiguration) {
+ public void setAdditionalConfig(final Map<String, String> additionalConfiguration) {
GeneratorMock.additionalCfg = additionalConfiguration;
}
@Override
- public void setResourceBaseDir(File resourceBaseDir) {
+ public void setResourceBaseDir(final File resourceBaseDir) {
GeneratorMock.resourceBaseDir = resourceBaseDir;
}
@Override
- public void setMavenProject(MavenProject project) {
+ public void setMavenProject(final MavenProject project) {
GeneratorMock.project = project;
}
}
*/
package org.opendaylight.yangtools.yang2sources.plugin;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Collection;
*/
package org.opendaylight.yangtools.yang.model.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
*/
package org.opendaylight.yangtools.yang.parser.impl;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
import org.junit.Before;
import org.junit.Test;
*/
package org.opendaylight.yangtools.yang.parser.impl;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
valid.enterYang_version_stmt(ctx);
}
- private static Revision_stmtContext mockModuleWithRevision(String date,
- String moduleName) {
+ private static Revision_stmtContext mockModuleWithRevision(final String date,
+ final String moduleName) {
Revision_stmtContext mockedRev = YangModelValidationTest.mockStatement(
Revision_stmtContext.class, date);
Revision_stmtsContext revs = YangModelValidationTest.mockStatement(
*/
package org.opendaylight.yangtools.yang.parser.impl;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
import static org.mockito.Mockito.mock;
import org.antlr.v4.runtime.tree.ParseTree;
}
}
- private Submodule_stmtContext mockSubmoduleParent(ParseTree child,
- String moduleName) {
+ private Submodule_stmtContext mockSubmoduleParent(final ParseTree child,
+ final String moduleName) {
Submodule_stmtContext ctx = YangModelValidationTest.mockStatement(
Submodule_stmtContext.class, moduleName);
YangModelValidationTest.addChild(ctx, child);
*/
package org.opendaylight.yangtools.yang.parser.impl;
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.Sets;
+
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
+
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
}
}
- assertThat(thrown, is(3));
+ assertEquals(3, thrown);
}
@Test(expected = YangValidationException.class)
types.add(Deviate_delete_stmtContext.class);
int count = ValidationUtil.countPresentChildrenOfType(ctx, types);
- assertThat(count, is(2));
+ assertEquals(2, count);
}
@Test(expected = YangValidationException.class)
}
}
- private Import_stmtContext mockImport(String name, String prefixName) {
+ private Import_stmtContext mockImport(final String name, final String prefixName) {
Import_stmtContext impor = mockStatement(Import_stmtContext.class, name);
Prefix_stmtContext prefix = mockStatement(Prefix_stmtContext.class, prefixName);
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
- private Include_stmtContext mockInclude(String name) {
+ private Include_stmtContext mockInclude(final String name) {
Include_stmtContext incl = mockStatement(Include_stmtContext.class, name);
Revision_date_stmtContext revDate = mockStatement(Revision_date_stmtContext.class, getFormattedDate());
return incl;
}
- static void mockName(ParseTree stmt, String name) {
+ static void mockName(final ParseTree stmt, final String name) {
doReturn(1).when(stmt).getChildCount();
TerminalNode terminalNode = mock(TerminalNode.class);
doReturn(Collections.singletonList(terminalNode)).when(nameCtx).STRING();
}
- static <T extends ParseTree> T mockStatement(Class<T> stmtType, String name) {
+ static <T extends ParseTree> T mockStatement(final Class<T> stmtType, final String name) {
T stmt = stmtType.cast(mock(stmtType));
doReturn(0).when(stmt).getChildCount();
- if (name != null)
+ if (name != null) {
mockName(stmt, name);
+ }
return stmt;
}
- static void addChild(ParseTree parent, ParseTree child) {
+ static void addChild(final ParseTree parent, final ParseTree child) {
int childCount = parent.getChildCount() + 1;
doReturn(childCount).when(parent).getChildCount();
doReturn(child).when(parent).getChild(childCount - 1);
*/
package org.opendaylight.yangtools.yang.parser.util;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.core.AnyOf.anyOf;
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import com.google.common.collect.Sets;
+
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+
import org.hamcrest.Matcher;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.Module;
assertDependencyGraph(ModuleDependencySort.createModuleGraph(ModuleOrModuleBuilder.fromAll(
Collections.<Module>emptySet(), Arrays.asList(builders))));
- @SuppressWarnings("unchecked")
- Matcher<String> cOrD = anyOf(is(c.getName()), is(d.getName()));
+ Matcher<String> cOrD = anyOf(equalTo(c.getName()), equalTo(d.getName()));
assertThat(l.get(0).getName(), cOrD);
assertThat(l.get(1).getName(), cOrD);
- assertThat(l.get(2).getName(), is(b.getName()));
- assertThat(l.get(3).getName(), is(a.getName()));
+ assertEquals(b.getName(), l.get(2).getName());
+ assertEquals(a.getName(), l.get(3).getName());
}
@Test
List<Module> l = ModuleDependencySort.sort(builders);
- assertThat(l.get(0).getName(), is(c.getName()));
- assertThat(l.get(1).getName(), is(b.getName()));
- assertThat(l.get(2).getName(), is(a.getName()));
+ assertEquals(c.getName(), l.get(0).getName());
+ assertEquals(b.getName(), l.get(1).getName());
+ assertEquals(a.getName(), l.get(2).getName());
}
@Test(expected = YangValidationException.class)
}
private void assertEdgeCount(final Set<Edge> inEdges, final int i, final Set<Edge> outEdges, final int j) {
- assertThat(inEdges.size(), is(i));
- assertThat(outEdges.size(), is(j));
+ assertEquals(i, inEdges.size());
+ assertEquals(j, outEdges.size());
}
private void mockDependency(final ModuleBuilder a, final ModuleBuilder b) {
*/
package org.opendaylight.yangtools.yang.parser.util;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import com.google.common.collect.Sets;
+
import java.util.List;
import java.util.Set;
+
import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
List<Node> sorted = TopologicalSort.sort(nodes);
- assertThat(sorted.get(0), is(node4));
- assertThat(sorted.get(1), is(node2));
- assertThat(sorted.get(2), is(node3));
- assertThat(sorted.get(3), is(node1));
+ assertEquals(node4, sorted.get(0));
+ assertEquals(node2, sorted.get(1));
+ assertEquals(node3, sorted.get(2));
+ assertEquals(node1, sorted.get(3));
}
}