summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/components/monitoring
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
commitb8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch)
treef78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-ui/test/softwareProduct/components/monitoring
parent75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff)
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components/monitoring')
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js40
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/test.js153
2 files changed, 70 insertions, 123 deletions
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
index 24658f1b30..423a7b39f6 100644
--- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
@@ -19,11 +19,12 @@ import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
import SoftwareProductComponentsMonitoringView from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx';
-import {VSPComponentsMonitoringViewFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js';
+import {VSPComponentsMonitoringViewFactory, trap, poll, ves} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js';
import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
const version = VersionControllerUtilsFactory.build();
+
describe('SoftwareProductComponentsMonitoring Module Tests', function () {
it('should mapper exist', () => {
@@ -33,24 +34,36 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () {
it('should return empty file names', () => {
let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring: {}}};
var results = mapStateToProps({softwareProduct});
- expect(results.trapFilename).toEqual(undefined);
- expect(results.pollFilename).toEqual(undefined);
+ expect(results.filenames[trap]).toEqual(undefined);
+ expect(results.filenames[poll]).toEqual(undefined);
+ expect(results.filenames[ves]).toEqual(undefined);
});
it('should return trap file name', () => {
- const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true});
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createTrap: true});
+ let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
+ var results = mapStateToProps({softwareProduct});
+ expect(results.filenames[trap]).toEqual(monitoring[trap]);
+ expect(results.filenames[poll]).toEqual(undefined);
+ expect(results.filenames[ves]).toEqual(undefined);
+ });
+
+ it('should return ves events file name', () => {
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createVes: true});
let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
var results = mapStateToProps({softwareProduct});
- expect(results.trapFilename).toEqual(monitoring.trapFilename);
- expect(results.pollFilename).toEqual(undefined);
+ expect(results.filenames[ves]).toEqual(monitoring[ves]);
+ expect(results.filenames[poll]).toEqual(undefined);
+ expect(results.filenames[trap]).toEqual(undefined);
});
it('should return poll file names', () => {
- const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpPollFlag: true});
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createPoll: true});
let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
var results = mapStateToProps({softwareProduct});
- expect(results.trapFilename).toEqual(undefined);
- expect(results.pollFilename).toEqual(monitoring.pollFilename);
+ expect(results.filenames[poll]).toEqual(monitoring[poll]);
+ expect(results.filenames[trap]).toEqual(undefined);
+ expect(results.filenames[ves]).toEqual(undefined);
let renderer = TestUtils.createRenderer();
renderer.render(<SoftwareProductComponentsMonitoringView {...results} />);
@@ -58,12 +71,13 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () {
expect(renderedOutput).toBeTruthy();
});
- it('should return both file names', () => {
- const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true});
+ it('should return all file names', () => {
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createTrap: true, createVes: true, createPoll: true});
let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
var results = mapStateToProps({softwareProduct});
- expect(results.trapFilename).toEqual(monitoring.trapFilename);
- expect(results.pollFilename).toEqual(monitoring.pollFilename);
+ expect(results.filenames[poll]).toEqual(monitoring[poll]);
+ expect(results.filenames[trap]).toEqual(monitoring[trap]);
+ expect(results.filenames[ves]).toEqual(monitoring[ves]);
let renderer = TestUtils.createRenderer();
renderer.render(<SoftwareProductComponentsMonitoringView {...results} />);
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
index dd0f850a89..8fafcdb968 100644
--- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
@@ -18,8 +18,9 @@ import mockRest from 'test-utils/MockRest.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductComponentsMonitoringConstants from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js';
import SoftwareProductComponentsMonitoringActionHelper from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js';
+import {fileTypes} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js';
-import {VSPComponentsMonitoringRestFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js';
+import {VSPComponentsMonitoringRestFactory, trap, poll, ves} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js';
import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
const softwareProductId = '123';
@@ -40,171 +41,103 @@ describe('Software Product Components Monitoring Module Tests', function () {
let emptyResult = VSPComponentsMonitoringRestFactory.build();
mockRest.addHandler('fetch', ({ baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`);
return emptyResult;
});
- SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
- softwareProductId,
- version,
- componentId
- });
- setTimeout(()=> {
+ return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => {
var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual(emptyResult.snmpPoll);
- expect(monitoring.trapFilename).toEqual(emptyResult.snmpTrap);
+ expect(monitoring[trap]).toEqual(emptyResult[trap]);
+ expect(monitoring[poll]).toEqual(emptyResult[poll]);
+ expect(monitoring[ves]).toEqual(emptyResult[ves]);
done();
- }, 0);
+ });
+
});
it('Fetch for existing files - only snmp trap file exists', done => {
- let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true});
+ let response = VSPComponentsMonitoringRestFactory.build({}, {createTrap: true});
mockRest.addHandler('fetch', ({ baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`);
return response;
});
- SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
- softwareProductId,
- version,
- componentId
- });
- setTimeout(()=> {
- var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual(response.snmpPoll);
- expect(monitoring.trapFilename).toEqual(response.snmpTrap);
- done();
- }, 0);
- });
-
- it('Fetch for existing files - only snmp poll file exists', done => {
- let response = VSPComponentsMonitoringRestFactory.build({}, {snmpPollFlag: true});
+ return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => {
- mockRest.addHandler('fetch', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
- return response;
- });
-
- SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
- softwareProductId,
- version,
- componentId
- });
- setTimeout(()=> {
var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual(response.snmpPoll);
- expect(monitoring.trapFilename).toEqual(response.snmpTrap);
+ expect(monitoring[poll]).toEqual(undefined);
+ expect(monitoring[trap]).toEqual(response[trap]);
+ expect(monitoring[ves]).toEqual(undefined);
done();
- }, 0);
+ });
});
- it('Fetch for existing files - both files exist', done => {
- let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true});
+
+ it('Fetch for existing files - all files exist', done => {
+ let response = VSPComponentsMonitoringRestFactory.build({}, {createSnmp: true, createPoll: true, createVes: true});
mockRest.addHandler('fetch', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`);
return response;
});
- SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
- softwareProductId,
- version,
- componentId
- });
- setTimeout(()=> {
+ return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => {
+
var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual(response.snmpPoll);
- expect(monitoring.trapFilename).toEqual(response.snmpTrap);
+ expect(monitoring[trap]).toEqual(response[trap]);
+ expect(monitoring[poll]).toEqual(response[poll]);
+ expect(monitoring[ves]).toEqual(response[ves]);
done();
- }, 0);
+ });
});
- it('Upload snmp trap file', done => {
+ it('Upload file', done => {
mockRest.addHandler('post', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap/upload`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads/types/${fileTypes.SNMP_TRAP}`);
return {};
});
var debug = {hello: 'world'};
let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});;
let formData = new FormData();
formData.append('upload', file);
- SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, {
+ return SoftwareProductComponentsMonitoringActionHelper.uploadFile(store.dispatch, {
softwareProductId,
version,
componentId,
formData,
fileSize: file.size,
- type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP
- });
- setTimeout(()=> {
+ type: fileTypes.SNMP_TRAP
+ }).then(() => {
var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual(undefined);
- expect(monitoring.trapFilename).toEqual('blob');
+ expect(monitoring[poll]).toEqual(undefined);
+ expect(monitoring[ves]).toEqual(undefined);
+ expect(monitoring[trap]).toEqual('blob');
done();
- }, 0);
- });
- it('Upload snmp poll file', done => {
- mockRest.addHandler('post', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp/upload`);
- return {};
- });
- var debug = {hello: 'world'};
- let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});;
- let formData = new FormData();
- formData.append('upload', file);
- SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, {
- softwareProductId,
- version,
- componentId,
- formData,
- fileSize: file.size,
- type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL
});
- setTimeout(()=> {
- var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual('blob');
- expect(monitoring.trapFilename).toEqual(undefined);
- done();
- }, 0);
});
it('Delete snmp trap file', done => {
mockRest.addHandler('destroy', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads/types/${fileTypes.SNMP_TRAP}`);
return {};
});
- SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, {
- softwareProductId,
- version,
- componentId,
- type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP
- });
- setTimeout(()=> {
- var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.trapFilename).toEqual(undefined);
- done();
- }, 0);
- });
- it('Delete snmp poll file', done => {
- mockRest.addHandler('destroy', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
- return {};
- });
- SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, {
+
+ return SoftwareProductComponentsMonitoringActionHelper.deleteFile(store.dispatch, {
softwareProductId,
version,
componentId,
- type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL
- });
- setTimeout(()=> {
+ type: fileTypes.SNMP_TRAP
+ }).then((dispatch) => {
var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
- expect(monitoring.pollFilename).toEqual(undefined);
+ expect(monitoring[trap]).toEqual(undefined);
done();
- }, 0);
+ });
});
+
+
});