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);
}
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());
}
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());
}
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());
}
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;
}
Aggregations