@Test public void shouldRetrieveTheStatus() { when(bundleContext.getServiceReference(PlatformStatusManager.class.getName())).thenReturn(ref); when(bundleContext.getService(ref)).thenReturn(statusManager); PlatformStatus statusFromMgr = buildStatus(); when(statusManager.getCurrentStatus()).thenReturn(statusFromMgr); PlatformStatus returnedStatus = platformStatusProxy.getCurrentStatus(); assertTrue(statusFromMgr != returnedStatus); assertStatus(returnedStatus); }
public PlatformStatus getCurrentStatus() { Object mgr = getStatusManager(); if (mgr == null) { LOGGER.debug("Status manager unavailable"); return new PlatformStatus(); } else { try { Object status = MethodUtils.invokeExactMethod(mgr, "getCurrentStatus", new Object[0]); return convertStatusBetweenClassLoaders(status); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new StatusProxyException("Unable to retrieve status from the manager instance", e); } } }
PlatformStatusProxy { public PlatformStatus getCurrentStatus() { Object mgr = getStatusManager(); if (mgr == null) { LOGGER.debug("Status manager unavailable"); return new PlatformStatus(); } else { try { Object status = MethodUtils.invokeExactMethod(mgr, "getCurrentStatus", new Object[0]); return convertStatusBetweenClassLoaders(status); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new StatusProxyException("Unable to retrieve status from the manager instance", e); } } } }
PlatformStatusProxy { public PlatformStatus getCurrentStatus() { Object mgr = getStatusManager(); if (mgr == null) { LOGGER.debug("Status manager unavailable"); return new PlatformStatus(); } else { try { Object status = MethodUtils.invokeExactMethod(mgr, "getCurrentStatus", new Object[0]); return convertStatusBetweenClassLoaders(status); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new StatusProxyException("Unable to retrieve status from the manager instance", e); } } } PlatformStatusProxy(BundleContext bundleContext); }
PlatformStatusProxy { public PlatformStatus getCurrentStatus() { Object mgr = getStatusManager(); if (mgr == null) { LOGGER.debug("Status manager unavailable"); return new PlatformStatus(); } else { try { Object status = MethodUtils.invokeExactMethod(mgr, "getCurrentStatus", new Object[0]); return convertStatusBetweenClassLoaders(status); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new StatusProxyException("Unable to retrieve status from the manager instance", e); } } } PlatformStatusProxy(BundleContext bundleContext); PlatformStatus getCurrentStatus(); }
PlatformStatusProxy { public PlatformStatus getCurrentStatus() { Object mgr = getStatusManager(); if (mgr == null) { LOGGER.debug("Status manager unavailable"); return new PlatformStatus(); } else { try { Object status = MethodUtils.invokeExactMethod(mgr, "getCurrentStatus", new Object[0]); return convertStatusBetweenClassLoaders(status); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new StatusProxyException("Unable to retrieve status from the manager instance", e); } } } PlatformStatusProxy(BundleContext bundleContext); PlatformStatus getCurrentStatus();  }