use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariClusterSetupServiceTest method testApiAvailableWhenPollerReturnFalseThenApiShouldBeNotAvailable.
@Test
public void testApiAvailableWhenPollerReturnFalseThenApiShouldBeNotAvailable() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
AmbariClient ambariClient = ambariClient();
when(ambariPollingServiceProvider.isAmbariAvailable(stack, ambariClient)).thenReturn(false);
when(clientFactory.getAmbariClient(stack, stack.getCluster())).thenReturn(ambariClient);
boolean available = underTest.available(stack);
verify(ambariPollingServiceProvider, times(1)).isAmbariAvailable(stack, ambariClient);
verify(clientFactory, times(1)).getAmbariClient(stack, stack.getCluster());
Assert.assertFalse(available);
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariHostsWithNamesTest method testAmbariHostsWithNames.
@Test
public void testAmbariHostsWithNames() {
Stack stack = TestUtil.stack();
List<String> hostNames = Lists.newArrayList("hostname1", "hostname2");
AmbariClient ambariClient = mock(AmbariClient.class);
AmbariHostsWithNames ambariHostsWithNames = new AmbariHostsWithNames(stack, ambariClient, hostNames);
Assert.assertEquals(stack, ambariHostsWithNames.getStack());
Assert.assertEquals(hostNames, ambariHostsWithNames.getHostNames());
Assert.assertEquals(ambariClient, ambariHostsWithNames.getAmbariClient());
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariSmartSenseCapturerTest method testCaptureWheTriggerNeedsToBeDoneAndNoExceptionOccured.
@Test
public void testCaptureWheTriggerNeedsToBeDoneAndNoExceptionOccured() {
Optional<SmartSenseSubscription> smartSenseSubscription = Optional.empty();
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(ambariClient.smartSenseCapture(1)).thenReturn(1);
when(smartSenseSubscriptionService.getDefault()).thenReturn(smartSenseSubscription);
when(smartsenseConfigurationLocator.smartsenseConfigurable(smartSenseSubscription)).thenReturn(true);
underTest.capture(1, ambariClient);
verify(ambariClient, times(1)).smartSenseCapture(anyInt());
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariSmartSenseCapturerTest method testCaptureWheTriggerNeedsToBeDoneAndExceptionOccured.
@Test
public void testCaptureWheTriggerNeedsToBeDoneAndExceptionOccured() {
Optional<SmartSenseSubscription> smartSenseSubscription = Optional.empty();
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(ambariClient.smartSenseCapture(1)).thenThrow(new AmbariServiceException("failed"));
when(smartSenseSubscriptionService.getDefault()).thenReturn(smartSenseSubscription);
when(smartsenseConfigurationLocator.smartsenseConfigurable(smartSenseSubscription)).thenReturn(true);
underTest.capture(1, ambariClient);
verify(ambariClient, times(1)).smartSenseCapture(anyInt());
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariUserHandlerTest method testCreateAmbariUserWhenExceptionOccuredThenTryingToCreateNewAmbariClientAndQueryAmbariVersion.
@Test
public void testCreateAmbariUserWhenExceptionOccuredThenTryingToCreateNewAmbariClientAndQueryAmbariVersion() throws CloudbreakException {
String newUserName = "newUserName";
String newPassword = "newPassword";
Stack stack = TestUtil.stack();
AmbariClient ambariClient = mock(AmbariClient.class);
when(ambariClient.createUser(newUserName, newPassword, true)).thenThrow(new AmbariServiceException("failed", new AmbariOperationFailedException("failed")));
when(ambariClient.ambariServerVersion()).thenReturn("2.4");
when(ambariClientFactory.getAmbariClient(stack, newUserName, newPassword)).thenReturn(ambariClient);
AmbariClient ambariClientResult = underTest.createAmbariUser(newUserName, newPassword, stack, ambariClient);
Assert.assertEquals(ambariClient, ambariClientResult);
verify(ambariClient, times(1)).createUser(newUserName, newPassword, true);
verify(ambariClientFactory, times(1)).getAmbariClient(stack, newUserName, newPassword);
verify(ambariClient, times(1)).ambariServerVersion();
}
Aggregations