Search in sources :

Example 11 with FlexSubscription

use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.

the class FlexSubscriptionServiceTest method testCreateShouldUpdateUsedForControllerFlagOfOldSubscriptionsWhenNewSubscriptionCreatedAsUsedForController.

@Test
public void testCreateShouldUpdateUsedForControllerFlagOfOldSubscriptionsWhenNewSubscriptionCreatedAsUsedForController() {
    when(flexRepo.countByNameAndAccount(anyString(), anyString())).thenReturn(0L);
    when(flexRepo.countBySubscriptionId(anyString())).thenReturn(0L);
    FlexSubscription subscription = getFlexSubscription("testFlexSubscription", "FLEX-000000000", true, false);
    FlexSubscription subscription1 = getFlexSubscription("testFlexSubscription1", "FLEX-000000001", true, true);
    when(flexRepo.save(subscription)).thenReturn(subscription);
    when(flexRepo.findAllByAccount(anyString())).thenReturn(Arrays.asList(subscription1, subscription));
    FlexSubscription result = underTest.create(subscription);
    verify(flexRepo, times(1)).save(subscription);
    verify(flexRepo, times(1)).save(Arrays.asList(subscription1, result));
    assertFalse(result.isDefault());
    assertTrue(result.isUsedForController());
    assertTrue(subscription1.isDefault());
    assertFalse(subscription1.isUsedForController());
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) Test(org.junit.Test)

Example 12 with FlexSubscription

use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.

the class FlexSubscriptionController method deletePublic.

@Override
public void deletePublic(String name) {
    IdentityUser cbUser = authenticatedUserService.getCbUser();
    FlexSubscription subscription = flexService.findByNameInAccount(name, cbUser.getUserId(), cbUser.getAccount());
    flexService.delete(subscription);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 13 with FlexSubscription

use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.

the class FlexSubscriptionController method setUsedForControllerInAccount.

@Override
public void setUsedForControllerInAccount(Long id) {
    IdentityUser identityUser = authenticatedUserService.getCbUser();
    FlexSubscription flexSubscription = flexService.findOneById(id);
    flexService.setUsedForControllerFlexSubscription(flexSubscription.getName(), identityUser);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 14 with FlexSubscription

use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.

the class FlexSubscriptionController method deletePrivate.

@Override
public void deletePrivate(String name) {
    FlexSubscription subscription = flexService.findOneByName(name);
    flexService.delete(subscription);
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 15 with FlexSubscription

use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.

the class FlexSubscriptionController method getPublic.

@Override
public FlexSubscriptionResponse getPublic(String name) {
    IdentityUser identityUser = authenticatedUserService.getCbUser();
    FlexSubscription subscription = flexService.findByNameInAccount(name, identityUser.getUserId(), identityUser.getAccount());
    return toJsonConverter.convert(subscription);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Aggregations

FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)22 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 Test (org.junit.Test)6 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 SmartSenseSubscription (com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)2 FlexUsageCbdInstanceJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)1 FileSystemConfigurationView (com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView)1 HostgroupView (com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)1 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)1 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 CloudbreakUsage (com.sequenceiq.cloudbreak.domain.CloudbreakUsage)1 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)1 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)1 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 IOException (java.io.IOException)1