### Question:
StartBrokerMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException { if (skip) { getLog().info("Skipped execution of ActiveMQ Broker"); return; } addActiveMQSystemProperties(); getLog().info("Loading broker configUri: " + configUri); if (this.xBeanFileResolver.isXBeanFile(configUri)) { getLog().debug("configUri before transformation: " + configUri); configUri = this.xBeanFileResolver.toUrlCompliantAbsolutePath(configUri); getLog().debug("configUri after transformation: " + configUri); } this.useBrokerManager().start(fork, configUri); this.registerTransportConnectorUris(); getLog().info("Started the ActiveMQ Broker"); }  MavenProject getProject(); void setProject(MavenProject project); String getConfigUri(); void setConfigUri(String configUri); boolean isFork(); void setFork(boolean fork); boolean isSkip(); void setSkip(boolean skip); Properties getSystemProperties(); void setSystemProperties(Properties systemProperties); String getConnectorPropertyNameFormat(); void setConnectorPropertyNameFormat(String connectorPropertyNameFormat); MavenBrokerManager getBrokerManager(); void setBrokerManager(MavenBrokerManager brokerManager); XBeanFileResolver getxBeanFileResolver(); void setxBeanFileResolver(XBeanFileResolver xBeanFileResolver); @Override void execute(); static final String DEFAULT_CONNECTOR_PROPERTY_NAME_FORMAT; }### Answer:
@Test public void testExecute () throws Exception { this.startBrokerMojo.execute(); Mockito.verify(this.mockBrokerManager).start(false, "x-config-uri-x"); }
@Test public void testExecuteRegistersTransportConnectorMultiUri () throws Exception { this.createTestTransportConnectors("connector1", "connector2", "connector3"); this.startBrokerMojo.execute(); Mockito.verify(this.mockMavenProperties).setProperty("x-name-connector1", "x-pub-addr-for-connector1"); Mockito.verify(this.mockMavenProperties).setProperty("x-name-connector2", "x-pub-addr-for-connector2"); Mockito.verify(this.mockMavenProperties).setProperty("x-name-connector3", "x-pub-addr-for-connector3"); }
@Test public void testExceptionOnGetPublishableConnectString () throws Exception { TransportConnector mockTransportConnector = Mockito.mock(TransportConnector.class); Mockito.when(mockTransportConnector.toString()).thenReturn("x-conn-x"); Mockito.when(mockTransportConnector.getPublishableConnectString()).thenThrow(testException); this.transportConnectorList.add(mockTransportConnector); this.startBrokerMojo.execute(); Mockito.verify(this.mockMavenLog).warn("error on obtaining broker connector uri; connector=x-conn-x", this.testException); }
@Test public void testUseXbeanConfigFile () throws Exception { Mockito.when(this.mockXbeanFileResolver.isXBeanFile("x-config-uri-x")).thenReturn(true); Mockito.when(this.mockXbeanFileResolver.toUrlCompliantAbsolutePath("x-config-uri-x")) .thenReturn("x-transformed-uri-x"); this.startBrokerMojo.execute(); Mockito.verify(this.mockMavenLog).debug("configUri before transformation: x-config-uri-x"); Mockito.verify(this.mockMavenLog).debug("configUri after transformation: x-transformed-uri-x"); }
@Test public void testDoNotUseXbeanConfigFile () throws Exception { Mockito.when(this.mockXbeanFileResolver.isXBeanFile("x-config-uri-x")).thenReturn(false); this.startBrokerMojo.execute(); Mockito.verify(this.mockMavenLog, Mockito.times(0)).debug("configUri before transformation: x-config-uri-x"); Mockito.verify(this.mockMavenLog, Mockito.times(0)) .debug("configUri after transformation: x-transformed-uri-x"); }