use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionServiceTest method getDefaultForUserWhenDefaultSmartSenseIdIsSpecifiedButAndItsEqualsToTheSubscriptionId.
@Test
public void getDefaultForUserWhenDefaultSmartSenseIdIsSpecifiedButAndItsEqualsToTheSubscriptionId() {
ReflectionTestUtils.setField(underTest, "defaultSmartsenseId", DEPLOYMENT_SMARTSENSE_ID);
SmartSenseSubscription subscription = createSmartSenseSubscription();
subscription.setSubscriptionId(DEPLOYMENT_SMARTSENSE_ID);
when(repository.findByAccountAndOwner(user.getAccount(), user.getUserId())).thenReturn(subscription);
doNothing().when(authorizationService).hasReadPermission(subscription);
SmartSenseSubscription result = underTest.getDefaultForUser(user);
Assert.assertEquals("The given SmartSenseSubscription instance has got a unexpected update", subscription, result);
verify(authorizationService, times(1)).hasReadPermission(Matchers.<SmartSenseSubscription>any());
}
use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionServiceTest method testGetDefaultForUserWhenDefaultSmartSenseIdIsNotSpecifiedAndDefaultSubscriptionCouldBeFoundButNotAuthorized.
@Test
public void testGetDefaultForUserWhenDefaultSmartSenseIdIsNotSpecifiedAndDefaultSubscriptionCouldBeFoundButNotAuthorized() {
SmartSenseSubscription smartSenseSubscription = createSmartSenseSubscription();
String exceptionMessage = "Unable to identify SmartSense subscription for the user.";
when(repository.findByAccountAndOwner(user.getAccount(), user.getUserId())).thenReturn(smartSenseSubscription);
doThrow(new AccessDeniedException(exceptionMessage)).when(authorizationService).hasReadPermission(smartSenseSubscription);
thrown.expect(SmartSenseSubscriptionAccessDeniedException.class);
thrown.expectMessage(exceptionMessage);
underTest.getDefaultForUser(user);
verify(authorizationService, times(1)).hasReadPermission(Matchers.<SmartSenseSubscription>any());
}
use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription 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.cloudbreak.domain.SmartSenseSubscription 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.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class FlexSubscriptionServiceTest method getFlexSubscription.
private FlexSubscription getFlexSubscription(String name, String subscriptionId, boolean usedForController, boolean usedAsDefault) {
FlexSubscription subscription = new FlexSubscription();
subscription.setName(name);
subscription.setSubscriptionId(subscriptionId);
subscription.setAccount("BIGACCOUNT");
subscription.setOwner("MINE");
subscription.setUsedForController(usedForController);
subscription.setDefault(usedAsDefault);
SmartSenseSubscription sSSubscription = new SmartSenseSubscription();
subscription.setSmartSenseSubscription(sSSubscription);
return subscription;
}
Aggregations