use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionController method get.
@Override
public SmartSenseSubscriptionJson get() {
IdentityUser cbUser = authenticatedUserService.getCbUser();
SmartSenseSubscription subscription = smartSenseSubService.getDefaultForUser(cbUser);
return toJsonConverter.convert(subscription);
}
use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionServiceTest method createSmartSenseSubscription.
private SmartSenseSubscription createSmartSenseSubscription() {
SmartSenseSubscription subscription = new SmartSenseSubscription();
subscription.setSubscriptionId(OLD_SMARTSENSE_ID);
subscription.setAccount(user.getAccount());
subscription.setOwner(user.getUserId());
subscription.setPublicInAccount(true);
return subscription;
}
use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionServiceTest method getDefaultForUserWhenDefaultSmartSenseIdIsSpecifiedAndDefaultSubscriptionNeedsToBeUpdated.
@Test
public void getDefaultForUserWhenDefaultSmartSenseIdIsSpecifiedAndDefaultSubscriptionNeedsToBeUpdated() {
ReflectionTestUtils.setField(underTest, "defaultSmartsenseId", DEPLOYMENT_SMARTSENSE_ID, String.class);
SmartSenseSubscription smartSenseSubscription = createSmartSenseSubscription();
when(repository.findByAccountAndOwner(user.getAccount(), user.getUserId())).thenReturn(smartSenseSubscription);
doNothing().when(authorizationService).hasReadPermission(smartSenseSubscription);
SmartSenseSubscription result = underTest.getDefaultForUser(user);
verify(repository, times(1)).save(Matchers.<SmartSenseSubscription>any());
Assert.assertEquals(DEPLOYMENT_SMARTSENSE_ID, result.getSubscriptionId());
}
use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionServiceTest method getDefaultForUserWhenDefaultSmartSenseIdIsSpecifiedAndDefaultSubscriptionCouldNotBeFound.
@Test
public void getDefaultForUserWhenDefaultSmartSenseIdIsSpecifiedAndDefaultSubscriptionCouldNotBeFound() {
ReflectionTestUtils.setField(underTest, "defaultSmartsenseId", DEPLOYMENT_SMARTSENSE_ID);
when(repository.findByAccountAndOwner(user.getAccount(), user.getUserId())).thenReturn(null);
doNothing().when(authorizationService).hasReadPermission(any(SmartSenseSubscription.class));
SmartSenseSubscription result = underTest.getDefaultForUser(user);
verify(repository, times(1)).save(Matchers.<SmartSenseSubscription>any());
Assert.assertEquals(DEPLOYMENT_SMARTSENSE_ID, result.getSubscriptionId());
}
use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionServiceTest method getDefaultForUserWhenDefaultSmartSenseIdIsNotSpecifiedAndDefaultSubscriptionCouldBeFound.
@Test
public void getDefaultForUserWhenDefaultSmartSenseIdIsNotSpecifiedAndDefaultSubscriptionCouldBeFound() {
SmartSenseSubscription smartSenseSubscription = createSmartSenseSubscription();
when(repository.findByAccountAndOwner(user.getAccount(), user.getUserId())).thenReturn(smartSenseSubscription);
doNothing().when(authorizationService).hasReadPermission(smartSenseSubscription);
SmartSenseSubscription result = underTest.getDefaultForUser(user);
Assert.assertEquals(smartSenseSubscription, result);
verify(authorizationService, times(1)).hasReadPermission(smartSenseSubscription);
}
Aggregations