ReportedBeanRegistry { void register(Object object, ReportedBean reportedBean, boolean applicationPrefix, String namePrefix, Map<String, String> tags) throws InstanceAlreadyExistsException { requireNonNull(object, "object is null"); if (reportedBeans.putIfAbsent(new Reference(object), registrationInfo(reportedBean, applicationPrefix, namePrefix, tags)) != null) { throw new InstanceAlreadyExistsException(object + " is already registered"); } }    }
@Test public void testRegister() throws Exception { registry.register(new Object(), TESTING_REPORTED_BEAN, false, "TestingObject", TESTING_TAGS); assertEquals(registry.getReportedBeans(), ImmutableList.of(registrationInfo(TESTING_REPORTED_BEAN, false, "TestingObject", TESTING_TAGS))); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testRegisterLegacyNullName() throws Exception { registry.register(TESTING_REPORTED_BEAN, null); }
@Test(expectedExceptions = InstanceAlreadyExistsException.class, expectedExceptionsMessageRegExp = "com\\.proofpoint\\.reporting:name=TestingObject is already registered") public void testRegisterLegacyTwice() throws Exception { registry.register(TESTING_REPORTED_BEAN, TESTING_OBJECT_NAME); registry.register(TESTING_REPORTED_BEAN, TESTING_OBJECT_NAME); }