<commit_before>/* global by, element */
'use strict';

var applications = require('../applications/applications');
var components = require('../components/components');
var authentication = require('../authentication/authentication');
var common = require('../common/common');
var cloudsCommon = require('../admin/clouds_common');
var navigation = require('../common/navigation');
var cloudImageCommon = require('../admin/cloud_image');

var relationshipTypesByIds = {
  'hostedOn10': 'tosca.relationships.HostedOn:1.0',
  'dependsOn10': 'tosca.relationships.DependsOn:1.0'
};
module.exports.relationshipTypesByIds = relationshipTypesByIds;

var topologyTemplates = {
  'template1': {
    'tName': 'WarTemplate',
    'tDescription': 'Simple architecture with one JAVA, one COMPUTE and a WAR'
  },
  'template2': {
    'tName': 'SoftwareFactory',
    'tDescription': 'Continous integration platform'
  },
  'template3': {
    'tName': 'SoftwareFactory-Release',
    'tDescription': 'Continous integration platform with Jenkins, Sonar, git en version RELEASE..'
  },
  'template4': {
    'tName': 'JavaTomcatWar',
    'tDescription': 'Simple server with one compoue, java installed and tomcat running'
  }
};
module.exports.topologyTemplates = topologyTemplates;


// Action to be executed before each topology test
var beforeTopologyTest = function() {
  common.before();
  authentication.login('admin');
  cloudImageCommon.addNewCloudImage('Windows', 'windows', 'x86_64', 'Windows', '14.04', '1', '1', '1');
  cloudImageCommon.addNewCloudImage('Ubuntu', 'linux', 'x86_64', 'Ubuntu', '14.04', '1', '1', '1');
  cloudsCommon.goToCloudList();
  cloudsCommon.createNewCloud('testcloud');
  cloudsCommon.goToCloudDetail('testcloud');
  cloudsCommon.enableCloud();
  cloudsCommon.addNewFlavor('medium', '12', '480', '4096');
  cloudsCommon.assignPaaSResourceToFlavor("medium", "passIdFlavor1");
//  cloudsCommon.selectFirstImageOfCloud();
//  cloudsCommon.selectFirstImageOfCloud();
  cloudsCommon.selectAllImageOfCloud();
  cloudsCommon.assignPaaSResourceToImage("Windows", "passIdImage1");
  cloudsCommon.assignPaaSResourceToImage("Ubuntu", "passIdImage2");
  cloudsCommon.disableCloud();
  cloudsCommon.enableCloud();
  authentication.logout();

  authentication.login('applicationManager');
  applications.createApplication('Alien', 'Great Application');
  // Go to the app details page
  browser.element(by.binding('application.name')).click();
  navigation.go('applications', 'topology');
};
module.exports.beforeTopologyTest = beforeTopologyTest;

// Show "Add node template" tab
function showComponentsTab() {
  var componentsSearchTab = element(by.id('components-search'));
  expect(componentsSearchTab.isPresent()).toBe(true);
  componentsSearchTab.click();
  browser.waitForAngular();
}

// Add a node template
var addNodeTemplate = function(ntype, expectedId, archiveVersion, selectedVersion) {
  showComponentsTab();

  // search element before selection
  var searchImput = element(by.model('searchedKeyword'));
  // TODO : should search by any word in the nodetype BUT the type is not
  // analyzed
  // var nodeNameToSearch = expectedId.split('_');<commit_msg>ALIEN-609: Fix UI tests<commit_after>/* global by, element */
'use strict';

var applications = require('../applications/applications');
var components = require('../components/components');
var authentication = require('../authentication/authentication');
var common = require('../common/common');
var cloudsCommon = require('../admin/clouds_common');
var navigation = require('../common/navigation');
var cloudImageCommon = require('../admin/cloud_image');

var relationshipTypesByIds = {
  'hostedOn10': 'tosca.relationships.HostedOn:1.0',
  'dependsOn10': 'tosca.relationships.DependsOn:1.0'
};
module.exports.relationshipTypesByIds = relationshipTypesByIds;

var topologyTemplates = {
  'template1': {
    'tName': 'WarTemplate',
    'tDescription': 'Simple architecture with one JAVA, one COMPUTE and a WAR'
  },
  'template2': {
    'tName': 'SoftwareFactory',
    'tDescription': 'Continous integration platform'
  },
  'template3': {
    'tName': 'SoftwareFactory-Release',
    'tDescription': 'Continous integration platform with Jenkins, Sonar, git en version RELEASE..'
  },
  'template4': {
    'tName': 'JavaTomcatWar',
    'tDescription': 'Simple server with one compoue, java installed and tomcat running'
  }
};
module.exports.topologyTemplates = topologyTemplates;


// Action to be executed before each topology test
var beforeTopologyTest = function() {
  common.before();
  authentication.login('admin');
  cloudImageCommon.addNewCloudImage('Windows', 'windows', 'x86_64', 'Windows', '14.04', '1', '1', '1');
  cloudImageCommon.addNewCloudImage('Ubuntu', 'linux', 'x86_64', 'Ubuntu', '14.04', '1', '1', '1');
  cloudsCommon.goToCloudList();
  cloudsCommon.createNewCloud('testcloud');
  cloudsCommon.goToCloudDetail('testcloud');
  cloudsCommon.enableCloud();
  cloudsCommon.addNewFlavor('medium', '12', '480', '4096');
  cloudsCommon.assignPaaSResourceToFlavor("medium", "passIdFlavor1");
  cloudsCommon.selectAllImageOfCloud();
  cloudsCommon.assignPaaSResourceToImage("Windows", "passIdImage1");
  cloudsCommon.assignPaaSResourceToImage("Ubuntu", "passIdImage2");
  cloudsCommon.goToCloudDetail('testcloud');
  cloudsCommon.disableCloud();
  cloudsCommon.enableCloud();
  authentication.logout();

  authentication.login('applicationManager');
  applications.createApplication('Alien', 'Great Application');
  // Go to the app details page
  browser.element(by.binding('application.name')).click();
  navigation.go('applications', 'topology');
};
module.exports.beforeTopologyTest = beforeTopologyTest;

// Show "Add node template" tab
function showComponentsTab() {
  var componentsSearchTab = element(by.id('components-search'));
  expect(componentsSearchTab.isPresent()).toBe(true);
  componentsSearchTab.click();
  browser.waitForAngular();
}

// Add a node template
var addNodeTemplate = function(ntype, expectedId, archiveVersion, selectedVersion) {
  showComponentsTab();

  // search element before selection
  var searchImput = element(by.model('searchedKeyword'));
  // TODO : should search by any word in the nodetype BUT the type is not
  // analyzed
  // var nodeNameToSearch = expectedId.split('_');
{'fraction_non_alphanumeric': 0.1480894244490249, 'fraction_numerical': 0.015062628825114952, 'mean_word_length': 5.7177848775292865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4331319', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1860, 'n_words': 403}