import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class DataTreeIdentifierTest {
+
private static final DataTreeIdentifier<TestDataObject1> TEST_IDENTIFIER1 = DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(TestDataObject1.class));
private static final DataTreeIdentifier<TestDataObject2> TEST_IDENTIFIER2 = DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(TestDataObject2.class));
+ @Test
+ public void basicTest() throws Exception {
+ assertEquals(LogicalDatastoreType.OPERATIONAL, TEST_IDENTIFIER1.getDatastoreType());
+ assertEquals(InstanceIdentifier.create(TestDataObject1.class), TEST_IDENTIFIER1.getRootIdentifier());
+ }
+
@Test
public void containsTest() {
assertTrue("Contains", TEST_IDENTIFIER1.contains(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
@Test
public void equalsTest() {
+ assertTrue("Equals", TEST_IDENTIFIER1.equals(TEST_IDENTIFIER1));
assertTrue("Equals", TEST_IDENTIFIER1.equals(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(TestDataObject1.class))));
assertFalse("Different", TEST_IDENTIFIER1.equals(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.create(TestDataObject1.class))));
assertFalse("Different", TEST_IDENTIFIER1.equals(TEST_IDENTIFIER2));
+ assertFalse("Equals null", TEST_IDENTIFIER1.equals(null));
+ assertFalse("Different object", TEST_IDENTIFIER1.equals(new Object()));
}
private static class TestDataObject1 implements DataObject {
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.binding.data.codec.impl;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeCodec;
+
+public class NonCachingCodecTest {
+
+ @Test
+ public void basicTest() throws Exception {
+ final BindingNormalizedNodeCodec codec = mock(BindingNormalizedNodeCodec.class);
+ doReturn(null).when(codec).serialize(null);
+ doReturn(null).when(codec).deserialize(null);
+ final NonCachingCodec nonCachingCodec = new NonCachingCodec<>(codec);
+ nonCachingCodec.serialize(null);
+ verify(codec).serialize(null);
+ nonCachingCodec.deserialize(null);
+ verify(codec).deserialize(null);
+ }
+}
\ No newline at end of file
<artifactId>mockito-configuration</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<scm>
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.common.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import javax.annotation.Nonnull;
-import org.junit.Test;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.common.RpcError;
-
-public class BasicExceptionTests {
-
- private static final RpcError RPC_ERROR = mock(RpcError.class);
-
- @Test(expected = TransactionCommitFailedException.class)
- public void transactionCommitFailedExceptionTest() throws Exception {
- throw new TransactionCommitFailedException("test", RPC_ERROR);
- }
-
- @Test(expected = TransactionCommitDeadlockException.class)
- public void transactionCommitDeadlockExceptionTest() throws Exception {
- throw new TransactionCommitDeadlockException(TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER
- .get().getMessage(), RPC_ERROR);
- }
-
- @Test(expected = TransactionChainClosedException.class)
- public void transactionChainClosedExceptionTest() throws Exception {
- throw new TransactionChainClosedException("test");
- }
-
- @Test(expected = TransactionChainClosedException.class)
- public void transactionChainClosedExceptionWithNullCauseTest() throws Exception {
- throw new TransactionChainClosedException("test", null);
- }
-
- @Test(expected = ReadFailedException.class)
- public void readFailedExceptionTest() throws Exception {
- throw new ReadFailedException("test", RPC_ERROR);
- }
-
- @Test(expected = ReadFailedException.class)
- public void readFailedExceptionWithThrowableTest() throws Exception {
-
- throw new ReadFailedException("test", ReadFailedException.MAPPER.apply(
- new NullPointerException()).getCause(), RPC_ERROR);
- }
-
- @Test(expected = OptimisticLockFailedException.class)
- public void optimisticLockFailedExceptionTest() throws Exception {
- throw new OptimisticLockFailedException("test");
- }
-
- @Test(expected = DataStoreUnavailableException.class)
- public void dataStoreUnavailableExceptionTest() throws Exception {
- throw new DataStoreUnavailableException("test", null);
- }
-
- @Test(expected = DataValidationFailedException.class)
- public void dataValidationFailedExceptionTest() throws Exception {
- final TestClass testClass = new TestClass();
- final DataValidationFailedException dataValidationFailedException =
- new DataValidationFailedException(TestClass.class, testClass, "test");
-
- assertEquals(testClass, dataValidationFailedException.getPath());
- assertEquals(TestClass.class, dataValidationFailedException.getPathType());
-
- throw dataValidationFailedException;
- }
-
- private final class TestClass implements Path {
- @Override
- public boolean contains(@Nonnull final Path other) {
- return false;
- }
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import org.junit.Test;
+
+public class DataStoreUnavailableExceptionTest {
+
+ @Test(expected = DataStoreUnavailableException.class)
+ public void dataStoreUnavailableExceptionTest() throws Exception {
+ throw new DataStoreUnavailableException("test", null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.Path;
+
+public class DataValidationFailedExceptionTest {
+
+ @Test(expected = DataValidationFailedException.class)
+ public void dataValidationFailedExceptionTest() throws Exception {
+ final TestClass testClass = new TestClass();
+ final DataValidationFailedException dataValidationFailedException =
+ new DataValidationFailedException(TestClass.class, testClass, "test");
+
+ assertEquals(testClass, dataValidationFailedException.getPath());
+ assertEquals(TestClass.class, dataValidationFailedException.getPathType());
+
+ throw dataValidationFailedException;
+ }
+
+ private final class TestClass implements Path {
+ @Override
+ public boolean contains(@Nonnull final Path other) {
+ return false;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import org.junit.Test;
+
+public class OptimisticLockFailedExceptionTest {
+
+ @Test(expected = OptimisticLockFailedException.class)
+ public void optimisticLockFailedExceptionTest() throws Exception {
+ throw new OptimisticLockFailedException("test");
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.RpcError;
+
+public class ReadFailedExceptionTest {
+
+ @Test(expected = ReadFailedException.class)
+ public void readFailedExceptionTest() throws Exception {
+ throw new ReadFailedException("test", mock(RpcError.class));
+ }
+
+ @Test(expected = ReadFailedException.class)
+ public void readFailedExceptionWithThrowableTest() throws Exception {
+ throw new ReadFailedException("test", ReadFailedException.MAPPER.apply(
+ new NullPointerException()).getCause(), mock(RpcError.class));
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import org.junit.Test;
+
+public class TransactionChainClosedExceptionTest {
+
+ @Test(expected = TransactionChainClosedException.class)
+ public void transactionChainClosedExceptionTest() throws Exception {
+ throw new TransactionChainClosedException("test");
+ }
+
+ @Test(expected = TransactionChainClosedException.class)
+ public void transactionChainClosedExceptionWithNullCauseTest() throws Exception {
+ throw new TransactionChainClosedException("test", null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.RpcError;
+
+public class TransactionCommitDeadlockExceptionTest {
+
+ @Test(expected = TransactionCommitDeadlockException.class)
+ public void transactionCommitDeadlockExceptionTest() throws Exception {
+ throw new TransactionCommitDeadlockException(TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER
+ .get().getMessage(), mock(RpcError.class));
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.common.api;
+
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.RpcError;
+
+public class TransactionCommitFailedExceptionTest {
+
+ @Test(expected = TransactionCommitFailedException.class)
+ public void transactionCommitFailedExceptionTest() throws Exception {
+ throw new TransactionCommitFailedException("test", mock(RpcError.class));
+ }
+}
\ No newline at end of file