@Test
public void shouldRegisterSystemCommanderMBean() throws Exception {

    final String contextName = "my-context";
    final ObjectName objectName = mock(ObjectName.class, "mBeanName");
    when(mbeanServer.isRegistered(objectName)).thenReturn(false);
    when(contextNameProvider.getContextName()).thenReturn(contextName);
    when(commandMBeanNameProvider.create(contextName)).thenReturn(objectName);
    mBeanInstantiator.registerSystemCommanderMBean();
    verify(mbeanServer).registerMBean(systemCommander, objectName);
    verify(logger).info("Registering SystemCommander MBean using name 'mBeanName'");
}