ReportedBeanRegistry { void unregisterLegacy(ObjectName name) throws InstanceNotFoundException { ReportedBean remove = legacyReportedBeans.remove(name); if (remove == null) { throw new InstanceNotFoundException(name.getCanonicalName() + " not found"); } reportedBeans.remove(new Reference(remove)); }    }
@Test public void testUnRegisterLegacy() throws Exception { registry.register(TESTING_REPORTED_BEAN, TESTING_OBJECT_NAME); registry.unregisterLegacy(ObjectName.getInstance("com.proofpoint.reporting", "name", "TestingObject")); assertEquals(registry.getReportedBeans(), ImmutableList.of()); }
@Test(expectedExceptions = InstanceNotFoundException.class, expectedExceptionsMessageRegExp = "com\\.proofpoint\\.reporting:name=TestingObject not found") public void testUnRegisterLegacyNotFound() throws Exception { registry.unregisterLegacy(TESTING_OBJECT_NAME); }