@Test
public void shouldNotRegisterSystemCommanderMBeanIfAlreadyRegistered() throws Exception {

    final String contextName = "my-context";
    final ObjectName objectName = mock(ObjectName.class, "mBeanName");
    when(contextNameProvider.getContextName()).thenReturn(contextName);
    when(commandMBeanNameProvider.create(contextName)).thenReturn(objectName);
    when(mbeanServer.isRegistered(objectName)).thenReturn(true);
    mBeanInstantiator.registerSystemCommanderMBean();
    verify(mbeanServer, never()).registerMBean(systemCommander, objectName);
    verifyZeroInteractions(logger);
}