ReportExporter { public void unexportObject(Object object) { try { registry.unregister(object); } catch (InstanceNotFoundException e) { throw new ReportException(Reason.INSTANCE_NOT_FOUND, e.getMessage()); } } @Inject  ReportExporter(ReportedBeanRegistry registry, BucketIdProvider bucketIdProvider); void export(Object object, boolean applicationPrefix, String namePrefix, Map<String, String> tags); void unexportObject(Object object); @Deprecated void export(String name, Object object); @Deprecated void export(ObjectName objectName, Object object); @Deprecated void unexport(String name); @Deprecated void unexport(ObjectName objectName);  }
@Test public void testUnexportObject() { reportExporter.export(TESTING_OBJECT, false, "TestingObject", ImmutableMap.of()); reportExporter.unexportObject(TESTING_OBJECT); assertEquals(registry.getReportedBeans(), ImmutableList.of()); }
@Test public void testUnexportObjectNotRegistered() { try { reportExporter.unexportObject(TESTING_OBJECT); fail("expected ReportException"); } catch (ReportException e) { assertEquals(e.getReason(), Reason.INSTANCE_NOT_FOUND); assertEquals(e.getMessage(), "Testing Object not found"); } }