### Question:
BundleMonitorExtension extends DefaultController implements MonitorExtension { @Route(method = HttpMethod.GET, uri = ".json") public Result bundles() { final List<BundleModel> list = BundleModel.bundles(context); return ok(ImmutableMap.of( "bundles", list, "events", counter.get(), "active", getActiveBundleCount(list), "installed", getInstalledBundleCount(list))).json(); }  @Validate void start(); @Invalidate void stop(); @Route(method = HttpMethod.GET, uri = "") Result bundle(); @Route(method = HttpMethod.GET, uri = ".json") Result bundles(); @Route(method = HttpMethod.GET, uri = "/{id}") Result toggleBundle(@Parameter("id") long id); @Route(method = HttpMethod.POST, uri = "/{id}") Result updateBundle(@Parameter("id") long id); @Route(method = HttpMethod.POST, uri = "") Result installBundle(@FormParameter("bundle") final FileItem bundle,
                                @FormParameter("start") @DefaultValue("false") final boolean startIfNeeded); @Route(method = HttpMethod.DELETE, uri = "/{id}") Result uninstallBundle(@Parameter("id") long id); @Override String label(); @Override String url(); @Override String category(); static boolean isFragment(Bundle bundle);  }### Answer:
@Test public void testBundles() { extension.start(); Bundle bundle1 = mock(Bundle.class); when(bundle1.getBundleId()).thenReturn(0l); when(bundle1.getSymbolicName()).thenReturn("System"); when(bundle1.getVersion()).thenReturn(new Version("4.4.4")); when(bundle1.getHeaders()).thenReturn(new Hashtable<String, String>()); when(bundle1.getState()).thenReturn(Bundle.ACTIVE); Bundle bundle2 = mock(Bundle.class); when(bundle2.getBundleId()).thenReturn(1l); when(bundle2.getSymbolicName()).thenReturn("iPOJO"); when(bundle2.getVersion()).thenReturn(new Version("1.0.0")); when(bundle2.getState()).thenReturn(Bundle.INSTALLED); when(bundle2.getHeaders()).thenReturn(new Hashtable<String, String>()); final Bundle[] array = {bundle1, bundle2}; when(context.getBundles()).thenReturn(array); Action.ActionResult result = action(new Invocation() { @Override public Result invoke() throws Throwable { return extension.bundles(); } }).invoke(); assertThat(result.getResult().getRenderable()).isNotNull(); Map<String, Object> map = (Map<String, Object>) result.getResult().getRenderable().content(); assertThat(map).containsEntry("events", 0).containsEntry("active", 1).containsEntry("installed", 1); assertThat((List<BundleModel>) map.get("bundles")).hasSize(2); extension.stop(); }