Search in sources :

Example 11 with SmartSenseSubscription

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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

Example 12 with SmartSenseSubscription

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;
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

Example 13 with SmartSenseSubscription

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());
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) Test(org.junit.Test)

Example 14 with SmartSenseSubscription

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());
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) Test(org.junit.Test)

Example 15 with SmartSenseSubscription

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);
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) Test(org.junit.Test)

Aggregations

SmartSenseSubscription (com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)24 Test (org.junit.Test)10 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)3 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)3 SmartSenseSubscriptionJson (com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson)2 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)2 FlexUsageControllerJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageControllerJson)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 HdfConfigs (com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs)1 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)1 FileSystemConfigurationView (com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView)1 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)1 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)1 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 IOException (java.io.IOException)1