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