Example #1
0
 setupStackServiceComponent: function() {
   /**
    * initialization of App.StackServiceComponent and App.StackService models
    * @type {*}
    */
   App.stackServiceMapper.map(require('test/service_components'));
 },
Example #2
0
  loadServiceComponentsSuccessCallback: function (jsonData) {
    var props = this.getDBProperties(['selectedServiceNames', 'installedServiceNames']);
    var savedSelectedServices = props.selectedServiceNames;
    var savedInstalledServices = props.installedServiceNames;
    this.set('content.selectedServiceNames', savedSelectedServices);
    this.set('content.installedServiceNames', savedInstalledServices);
    if (!savedSelectedServices) {
      jsonData.items.forEach(function (service) {
        service.StackServices.is_selected = true;
      }, this);
    } else {
      jsonData.items.forEach(function (service) {
        if (savedSelectedServices.contains(service.StackServices.service_name))
          service.StackServices.is_selected = true;
        else
          service.StackServices.is_selected = false;
      }, this);
    }

    if (!savedInstalledServices) {
      jsonData.items.forEach(function (service) {
        service.StackServices.is_installed = false;
      }, this);
    } else {
      jsonData.items.forEach(function (service) {
        if (savedInstalledServices.contains(service.StackServices.service_name))
          service.StackServices.is_installed = true;
        else
          service.StackServices.is_installed = false;
      }, this);
    }

    App.stackServiceMapper.mapStackServices(jsonData);
  },
 it('should sort and map data about services with their components', function () {
   App.stackServiceMapper.map(data);
   var services = App.StackService.find(),
     components = App.StackServiceComponent.find(),
     kafkaService = services.findProperty('serviceName', 'KAFKA');
   expect(services.mapProperty('serviceName')).to.eql(sortedServiceNames);
   expect(kafkaService.get('serviceComponents.length')).to.equal(1);
   Em.keys(serviceResult).forEach(function (key) {
     expect(kafkaService.get(key)).to.eql(serviceResult[key]);
   });
   Em.keys(componentResult).forEach(function (key) {
     expect(kafkaService.get('serviceComponents').toArray()[0].get(key)).to.eql(componentResult[key]);
   });
   Em.keys(componentResult).forEach(function (key) {
     expect(components.findProperty('componentName', 'KAFKA_BROKER').get(key)).to.eql(componentResult[key]);
   });
   expect(services.findProperty('serviceName', 'KERBEROS').get('isInstallable')).to.be.false;
   expect(services.findProperty('serviceName', 'KERBEROS').get('isSelected')).to.be.false;
   expect(components.findProperty('componentName', 'MYSQL_SERVER').get('customCommands')).to.be.empty;
 });
 beforeEach(function () {
   App.stackServiceMapper.clearStackModels();
 });