use of com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson in project cloudbreak by hortonworks.
the class FlexSubscriptionToJsonConverter method convert.
@Override
public FlexSubscriptionResponse convert(FlexSubscription source) {
FlexSubscriptionResponse json = new FlexSubscriptionResponse();
json.setId(source.getId());
json.setName(source.getName());
json.setOwner(source.getOwner());
json.setAccount(source.getAccount());
json.setPublicInAccount(source.isPublicInAccount());
json.setSubscriptionId(source.getSubscriptionId());
json.setSmartSenseSubscriptionId(source.getSmartSenseSubscription().getId());
SmartSenseSubscriptionJson smartSenseSubscriptionJson = smartSenseSubscriptionToSmartSenseSubscriptionJsonConverter.convert(source.getSmartSenseSubscription());
json.setSmartSenseSubscription(smartSenseSubscriptionJson);
json.setUsedAsDefault(source.isDefault());
json.setUsedForController(source.isUsedForController());
return json;
}
use of com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson in project cloudbreak by hortonworks.
the class SmartSenseSubscriptionToSmartSenseSubscriptionJsonConverter method convert.
@Override
public SmartSenseSubscriptionJson convert(SmartSenseSubscription source) {
SmartSenseSubscriptionJson json = new SmartSenseSubscriptionJson();
json.setId(source.getId());
json.setSubscriptionId(source.getSubscriptionId());
json.setOwner(source.getOwner());
json.setAccount(source.getAccount());
json.setPublicInAccount(source.isPublicInAccount());
json.setAutoGenerated(source.getSubscriptionId().startsWith("A-9990"));
return json;
}
use of com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson 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());
}
use of com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson 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);
}
Aggregations