- Mockito.verify(rpcProviderRegistry, times(AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC)).addRoutedRpcImplementation(
- Matchers.<Class<RpcService>>any(), Matchers.any(RpcService.class));
- Mockito.verify(routedRpcRegistration, times(AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC)).registerPath(
- NodeContext.class, nodePath);
- Mockito.verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(deviceContext);
+ @Test
+ public void testOnDeviceContextLevelDown() throws Exception {
+ rpcManager.onDeviceContextLevelDown(deviceInfo);
+ verify(deviceTerminationPhaseHandler).onDeviceContextLevelDown(deviceInfo);
+ }
+
+ /**
+ * On non null context close and onDeviceContextLevelDown should be called
+ */
+ @Test
+ public void onDeviceContextLevelDown1() {
+ rpcManager.addRecordToContexts(deviceInfo, removedContexts);
+ rpcManager.onDeviceContextLevelDown(deviceInfo);
+ verify(removedContexts,times(1)).close();
+ verify(deviceTerminationPhaseHandler,times(1)).onDeviceContextLevelDown(deviceInfo);
+ }
+
+
+ /**
+ * On null context only onDeviceContextLevelDown should be called
+ */
+ @Test
+ public void onDeviceContextLevelDown2() {
+ rpcManager.onDeviceContextLevelDown(deviceInfo);
+ verify(removedContexts,never()).close();
+ verify(deviceTerminationPhaseHandler,times(1)).onDeviceContextLevelDown(deviceInfo);
+
+ }
+
+ @Test
+ public void close() {
+ rpcManager.addRecordToContexts(deviceInfo,removedContexts);
+ rpcManager.close();
+ verify(removedContexts,atLeastOnce()).close();