Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / config / config-persister-impl / src / test / java / org / opendaylight / controller / config / persist / impl / ConfigPusherImplTest.java
index 3583e32e2626ca83464e8f7e54f69cac76f3b4bb..28f6ce83c8256ea712489547a598c61d4cdb3dda 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.config.persist.impl;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
@@ -21,6 +20,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
+import com.google.common.base.Throwables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import java.lang.management.ManagementFactory;
@@ -47,7 +47,7 @@ import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.util.ConfigRegistryClient;
 import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.w3c.dom.Element;
 
 public class ConfigPusherImplTest {
@@ -72,7 +72,7 @@ public class ConfigPusherImplTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        doReturn("content").when(yangStoreService).getModuleSource(any(ModuleIdentifier.class));
+        doReturn("content").when(yangStoreService).getModuleSource(any(SourceIdentifier.class));
         doReturn("mocked snapshot").when(mockedConfigSnapshot).toString();
         doReturn("<mocked-snapshot/>").when(mockedConfigSnapshot).getConfigSnapshot();
         doReturn(Collections.<Module>emptySet()).when(yangStoreService).getModules();
@@ -92,11 +92,12 @@ public class ConfigPusherImplTest {
 
         configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
         try {
-            configPusher.process(Lists.<AutoCloseable>newArrayList(), ManagementFactory.getPlatformMBeanServer(), mockedAggregator);
-        } catch(IllegalStateException e) {
-            assertNotNull(e.getCause());
-            assertTrue(e.getCause() instanceof ConfigPusherImpl.NotEnoughCapabilitiesException);
-            final Set<String> missingCaps = ((ConfigPusherImpl.NotEnoughCapabilitiesException) e.getCause()).getMissingCaps();
+            configPusher.process(Lists.<AutoCloseable>newArrayList(), ManagementFactory.getPlatformMBeanServer(),
+                    mockedAggregator, true);
+        } catch(final IllegalStateException e) {
+            Throwable cause = Throwables.getRootCause(e);
+            assertTrue(cause instanceof ConfigPusherImpl.NotEnoughCapabilitiesException);
+            final Set<String> missingCaps = ((ConfigPusherImpl.NotEnoughCapabilitiesException) cause).getMissingCaps();
             assertEquals(missingCaps.size(), 1);
             assertEquals(missingCaps.iterator().next(), "required-cap");
             return;
@@ -121,7 +122,7 @@ public class ConfigPusherImplTest {
         final ConfigPusherImpl configPusher = new ConfigPusherImpl(facadeFactory, 0, 0);
 
         configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
-        configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator);
+        configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator, true);
 
         verify(facade).executeConfigExecution(cfgExec);
         verify(facade).commitSilentTransaction();
@@ -144,10 +145,10 @@ public class ConfigPusherImplTest {
 
         configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
         try {
-            configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator);
-        } catch (IllegalStateException e) {
-            assertNotNull(e.getCause());
-            assertTrue(e.getCause() instanceof ConflictingVersionException);
+            configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator, true);
+        } catch (final IllegalStateException e) {
+            Throwable cause = Throwables.getRootCause(e);
+            assertTrue(cause instanceof ConflictingVersionException);
             return;
         }
 
@@ -174,7 +175,7 @@ public class ConfigPusherImplTest {
         final ConfigPusherImpl configPusher = new ConfigPusherImpl(facadeFactory, 5000, 5000);
 
         configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
-        configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator);
+        configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator, true);
 
         verify(facade, times(3)).executeConfigExecution(cfgExec);
         verify(facade, times(3)).commitSilentTransaction();