@Test public void ambariServerStartWithAgentInClusterWhenEverythingWorksFine() throws Exception { when(ambariServerBootstrap.call()).thenReturn(true); doReturn(ambariServerBootstrap) .when(underTestSpy) .ambariServerBootstrap( any(GatewayConfig.class), anyString(), any(Node.class), anyString(), any(LogVolumePath.class)); when(ambariAgentBootstrap.call()).thenReturn(true); doReturn(ambariAgentBootstrap) .when(underTestSpy) .ambariAgentBootstrap( any(GatewayConfig.class), anyString(), any(Node.class), anyString(), anyString(), any(LogVolumePath.class)); when(ambariServerDatabaseBootstrap.call()).thenReturn(true); doReturn(ambariServerDatabaseBootstrap) .when(underTestSpy) .ambariServerDatabaseBootstrap( any(GatewayConfig.class), anyString(), any(Node.class), any(LogVolumePath.class)); underTestSpy.startAmbariServer( containerOrchestratorCluster(gatewayConfig(), generateNodes(FIX_NODE_COUNT)), new ContainerConfig("serverdb", "0.0.1"), new ContainerConfig("serverdb", "0.0.1"), "azure", generateLogVolume(), true, exitCriteriaModel()); verify(underTestSpy, times(1)) .ambariAgentBootstrap( any(GatewayConfig.class), anyString(), any(Node.class), anyString(), anyString(), any(LogVolumePath.class)); }
@Test(expected = CloudbreakOrchestratorFailedException.class) public void ambariAgentStartInClusterWhenNullPointerOccurredAndOrchestratorFailedComes() throws Exception { when(ambariAgentBootstrap.call()).thenThrow(new NullPointerException("null")); doReturn(ambariAgentBootstrap) .when(underTestSpy) .ambariAgentBootstrap( any(GatewayConfig.class), anyString(), any(Node.class), anyString(), anyString(), any(LogVolumePath.class)); underTestSpy.startAmbariAgents( containerOrchestratorCluster(gatewayConfig(), generateNodes(FIX_NODE_COUNT)), new ContainerConfig("agent", "0.0.1"), "azure", generateLogVolume(), exitCriteriaModel()); }