Search in sources :

Example 16 with FlexSubscription

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

the class FlexSubscriptionServiceTest method testCreateShouldThrowBadRequestWhenSubscriptionExistsWithTheSameSubscriptionIdentifier.

@Test(expected = BadRequestException.class)
public void testCreateShouldThrowBadRequestWhenSubscriptionExistsWithTheSameSubscriptionIdentifier() {
    when(flexRepo.countByNameAndAccount(anyString(), anyString())).thenReturn(0L);
    when(flexRepo.countBySubscriptionId(anyString())).thenReturn(1L);
    FlexSubscription subscription = getFlexSubscription("testFlexSubscription1", "FLEX-000000001");
    underTest.create(subscription);
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) Test(org.junit.Test)

Example 17 with FlexSubscription

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

the class FlexSubscriptionServiceTest method testCreateShouldUpdateDefaultFlagsOfOldSubscriptionsWhenNewSubscriptionRequiresDefaultFlags.

@Test
public void testCreateShouldUpdateDefaultFlagsOfOldSubscriptionsWhenNewSubscriptionRequiresDefaultFlags() {
    when(flexRepo.countByNameAndAccount(anyString(), anyString())).thenReturn(0L);
    when(flexRepo.countBySubscriptionId(anyString())).thenReturn(0L);
    FlexSubscription subscription = getFlexSubscription("testFlexSubscription", "FLEX-000000000", true, true);
    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));
    assertTrue(result.isDefault());
    assertTrue(result.isUsedForController());
    assertFalse(subscription1.isDefault());
    assertFalse(subscription1.isUsedForController());
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) Test(org.junit.Test)

Example 18 with FlexSubscription

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

the class FlexSubscriptionServiceTest method testCreateShouldUpdateDefaultFlagOfOldSubscriptionsWhenNewSubscriptionCreatedAsDefault.

@Test
public void testCreateShouldUpdateDefaultFlagOfOldSubscriptionsWhenNewSubscriptionCreatedAsDefault() {
    when(flexRepo.countByNameAndAccount(anyString(), anyString())).thenReturn(0L);
    when(flexRepo.countBySubscriptionId(anyString())).thenReturn(0L);
    FlexSubscription subscription = getFlexSubscription("testFlexSubscription", "FLEX-000000000", false, true);
    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));
    assertTrue(result.isDefault());
    assertFalse(result.isUsedForController());
    assertFalse(subscription1.isDefault());
    assertTrue(subscription1.isUsedForController());
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) Test(org.junit.Test)

Example 19 with FlexSubscription

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

the class FlexSubscriptionServiceTest method testCreateShouldSetDefaultFlagsForTheFirstSavedSubscription.

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

Example 20 with FlexSubscription

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

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