X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsamples%2Ftoaster-provider%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Ftoaster%2Fprovider%2FOpenDaylightToasterTest.java;fp=opendaylight%2Fmd-sal%2Fsamples%2Ftoaster-provider%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Ftoaster%2Fprovider%2FOpenDaylightToasterTest.java;h=c6f0dc1d3f615b8159337ed22c891216dbcd2460;hb=310e1cf3dca0c2e94994a09c0faf7483d738e576;hp=1f5f0f7cd815df746708632e4fe6f0f8e87dc24b;hpb=3613d3cbde81af18aab2d5917491e9f9b3bf63ca;p=controller.git diff --git a/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java b/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java index 1f5f0f7cd8..c6f0dc1d3f 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java @@ -13,6 +13,7 @@ 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 com.google.common.base.Optional; import java.util.concurrent.Future; import org.junit.Ignore; @@ -32,63 +33,56 @@ import org.opendaylight.yangtools.yang.common.RpcResult; public class OpenDaylightToasterTest extends AbstractDataBrokerTest { - private static InstanceIdentifier TOASTER_IID = - InstanceIdentifier.builder( Toaster.class ).build(); + private static InstanceIdentifier TOASTER_IID = InstanceIdentifier.builder(Toaster.class).build(); OpendaylightToaster toaster; @Override protected void setupWithDataBroker(DataBroker dataBroker) { toaster = new OpendaylightToaster(); - toaster.setDataProvider( dataBroker ); + toaster.setDataBroker(dataBroker); /** * Doesn't look like we have support for the NotificationProviderService yet, so mock it * for now. */ - NotificationPublishService mockNotification = mock( NotificationPublishService.class ); - toaster.setNotificationProvider( mockNotification ); + NotificationPublishService mockNotification = mock(NotificationPublishService.class); + toaster.setNotificationProvider(mockNotification); } @Test public void testToasterInitOnStartUp() throws Exception { DataBroker broker = getDataBroker(); - ReadOnlyTransaction rTx = broker.newReadOnlyTransaction(); - Optional optional = rTx.read( LogicalDatastoreType.OPERATIONAL, TOASTER_IID ).get(); - assertNotNull( optional ); - assertTrue( "Operational toaster not present", optional.isPresent() ); + ReadOnlyTransaction readTx = broker.newReadOnlyTransaction(); + Optional optional = readTx.read(LogicalDatastoreType.OPERATIONAL, TOASTER_IID).get(); + assertNotNull(optional); + assertTrue("Operational toaster not present", optional.isPresent()); - Toaster toaster = optional.get(); + Toaster toasterData = optional.get(); - assertEquals( Toaster.ToasterStatus.Up, toaster.getToasterStatus() ); - assertEquals( new DisplayString("Opendaylight"), - toaster.getToasterManufacturer() ); - assertEquals( new DisplayString("Model 1 - Binding Aware"), - toaster.getToasterModelNumber() ); + assertEquals(Toaster.ToasterStatus.Up, toasterData.getToasterStatus()); + assertEquals(new DisplayString("Opendaylight"), toasterData.getToasterManufacturer()); + assertEquals(new DisplayString("Model 1 - Binding Aware"), toasterData.getToasterModelNumber()); - Optional configToaster = - rTx.read( LogicalDatastoreType.CONFIGURATION, TOASTER_IID ).get(); - assertFalse( "Didn't expect config data for toaster.", - configToaster.isPresent() ); + Optional configToaster = readTx.read(LogicalDatastoreType.CONFIGURATION, TOASTER_IID).get(); + assertFalse("Didn't expect config data for toaster.", configToaster.isPresent()); } @Test - @Ignore //ignored because it is not an e test right now. Illustrative purposes only. - public void testSomething() throws Exception{ - MakeToastInput toastInput = new MakeToastInputBuilder() - .setToasterDoneness( 1L ) - .setToasterToastType( WheatBread.class ) - .build(); + @Ignore //ignored because it is not a test right now. Illustrative purposes only. + public void testSomething() throws Exception { + MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(1L) + .setToasterToastType(WheatBread.class).build(); - //NOTE: In a real test we would want to override the Thread.sleep() to prevent our junit test - //for sleeping for a second... - Future> makeToast = toaster.makeToast( toastInput ); + // NOTE: In a real test we would want to override the Thread.sleep() to + // prevent our junit test + // for sleeping for a second... + Future> makeToast = toaster.makeToast(toastInput); RpcResult rpcResult = makeToast.get(); - assertNotNull( rpcResult ); - assertTrue( rpcResult.isSuccessful() ); - //etc + assertNotNull(rpcResult); + assertTrue(rpcResult.isSuccessful()); + // etc } - }