Search in sources :

Example 21 with SmartSenseSubscription

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

the class SmartSenseSubscriptionService method createSubscriptionFromIdentityUser.

@Nullable
private SmartSenseSubscription createSubscriptionFromIdentityUser(IdentityUser cbUser) {
    SmartSenseSubscription newSubscription = null;
    if (!StringUtils.isEmpty(defaultSmartsenseId)) {
        LOGGER.info("Generating default SmartSense subscription");
        newSubscription = new SmartSenseSubscription();
        newSubscription.setSubscriptionId(defaultSmartsenseId);
        newSubscription.setAccount(cbUser.getAccount());
        newSubscription.setOwner(cbUser.getUserId());
        newSubscription.setPublicInAccount(true);
        repository.save(newSubscription);
    }
    return newSubscription;
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) Nullable(javax.annotation.Nullable)

Example 22 with SmartSenseSubscription

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

the class SmartSenseSubscriptionToSmartSenseSubscriptionJsonConverterTest method convertWithExampleDataSource.

@Test
public void convertWithExampleDataSource() {
    SmartSenseSubscription source = mock(SmartSenseSubscription.class);
    Long id = Long.MAX_VALUE;
    String subscriptionId = "A-99900000-C-00000000";
    String owner = "Johnny Bravo";
    String account = "awesomeAccount";
    when(source.getId()).thenReturn(id);
    when(source.getSubscriptionId()).thenReturn(subscriptionId);
    when(source.getOwner()).thenReturn(owner);
    when(source.getAccount()).thenReturn(account);
    when(source.isPublicInAccount()).thenReturn(true);
    SmartSenseSubscriptionJson json = underTest.convert(source);
    assertNotNull("The returning SmartSenseSubscriptionJson should not be null.", json);
    assertEquals("The output ID from the json is not match for the expected.", id, json.getId());
    assertEquals("The output subscription ID from the json is not match for the expected.", subscriptionId, json.getSubscriptionId());
    assertEquals("The output owner from the json is not match for the expected.", owner, json.getOwner());
    assertEquals("The output account from the json is not match for the expected.", account, json.getAccount());
    assertEquals("The output public account value from the json is not match for the expected.", true, json.isPublicInAccount());
    assertEquals("The autoGenerated value from the json is not match for the expected.", true, json.isAutoGenerated());
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) SmartSenseSubscriptionJson(com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson) Test(org.junit.Test)

Example 23 with SmartSenseSubscription

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

the class SmartSenseSubscriptionControllerTest method testGetWhenSmartSenseSubscriptionIsValid.

@Test
public void testGetWhenSmartSenseSubscriptionIsValid() {
    SmartSenseSubscription subscription = createSmartSenseSubscription();
    when(authenticatedUserService.getCbUser()).thenReturn(identityUser);
    when(smartSenseSubService.getDefaultForUser(identityUser)).thenReturn(subscription);
    when(toJsonConverter.convert(subscription)).thenCallRealMethod();
    SmartSenseSubscriptionJson json = underTest.get();
    Assert.assertNotNull(json);
    verify(authenticatedUserService, times(1)).getCbUser();
    verify(smartSenseSubService, times(1)).getDefaultForUser(identityUser);
    verify(toJsonConverter, times(1)).convert(subscription);
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) SmartSenseSubscriptionJson(com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson) Test(org.junit.Test)

Example 24 with SmartSenseSubscription

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

the class FlexUsageGenerator method getFlexUsageControllerJson.

private FlexUsageControllerJson getFlexUsageControllerJson(List<CloudbreakUsage> usages, Optional<CloudbreakUsage> aUsage) {
    Optional<SmartSenseSubscription> smartSenseSubscriptionOptional = smartSenseSubscriptionService.getDefault();
    FlexUsageControllerJson controllerJson = new FlexUsageControllerJson();
    String parentUuid = cloudbreakNodeConfig.getInstanceUUID();
    controllerJson.setGuid(parentUuid);
    controllerJson.setInstanceId(parentUuid);
    controllerJson.setProvider(cbInstanceProvider);
    controllerJson.setRegion(cbInstanceRegion);
    aUsage.ifPresent(cloudbreakUsage -> controllerJson.setUserName(getUserEmail(cloudbreakUsage)));
    smartSenseSubscriptionOptional.ifPresent(smartSenseSubscription -> controllerJson.setSmartSenseId(smartSenseSubscription.getSubscriptionId()));
    return controllerJson;
}
Also used : FlexUsageControllerJson(com.sequenceiq.cloudbreak.api.model.flex.FlexUsageControllerJson) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

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