diff --git a/openecomp-ui/test/licenseModel/licenseAgreement/test.js b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
index a6e8a3d..442f7bf 100644
--- a/openecomp-ui/test/licenseModel/licenseAgreement/test.js
+++ b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
@@ -1,75 +1,54 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
  */
-
-import {expect} from 'chai';
 import deepFreeze from 'deep-freeze';
+import pickBy from 'lodash/pickBy';
 import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
 import {storeCreator} from 'sdc-app/AppStore.js';
 import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
 
+import { LicenseAgreementStoreFactory, LicenseAgreementDispatchFactory, LicenseAgreementPostFactory, LicenseAgreementPutFactory } from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
 
 describe('License Agreement Module Tests', () => {
 
 	const LICENSE_MODEL_ID = '777';
+	const version = VersionControllerUtilsFactory.build().version;
 
 	it('Load License Agreement List', () => {
-		const licenseAgreementList = [
-			{
-				id: '0',
-				name: 'name0',
-				description: 'description0',
-				licenseTerm: 'licenseTerm0',
-				requirementsAndConstrains: 'req_and_constraints0',
-				featureGroupsIds: ['77']
-			}
-		];
-		deepFreeze(licenseAgreementList);
+		const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory);
+
 		const store = storeCreator();
 		deepFreeze(store.getState());
 
 		const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', licenseAgreementList);
 
 		mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
-			expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`);
-			expect(data).to.equal(undefined);
-			expect(options).to.equal(undefined);
+			expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
+			expect(data).toEqual(undefined);
+			expect(options).toEqual(undefined);
 			return {results: licenseAgreementList};
 		});
-		return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
-			expect(store.getState()).to.deep.equal(expectedStore);
+		return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+			expect(store.getState()).toEqual(expectedStore);
 		});
 	});
 
 	it('Delete License Agreement', () => {
-		const licenseAgreementList = [
-			{
-				id: '0',
-				name: 'name0',
-				description: 'description0',
-				licenseTerm: 'licenseTerm0',
-				requirementsAndConstrains: 'req_and_constraints0',
-				featureGroupsIds: ['77']
-			}
-		];
-		deepFreeze(licenseAgreementList);
+		const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1);
 		const store = storeCreator({
 			licenseModel: {
 				licenseAgreement: {
@@ -78,57 +57,49 @@
 			}
 		});
 		deepFreeze(store.getState());
-		const toBeDeletedLicenseAgreementId = '0';
+		const toBeDeletedLicenseAgreementId = licenseAgreementList[0].id;
 		const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', []);
 
 		mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
-			expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeDeletedLicenseAgreementId}`);
-			expect(data).to.equal(undefined);
-			expect(options).to.equal(undefined);
+			expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeDeletedLicenseAgreementId}`);
+			expect(data).toEqual(undefined);
+			expect(options).toEqual(undefined);
 		});
 
 		return LicenseAgreementActionHelper.deleteLicenseAgreement(store.dispatch, {
 			licenseAgreementId: toBeDeletedLicenseAgreementId,
-			licenseModelId: LICENSE_MODEL_ID
+			licenseModelId: LICENSE_MODEL_ID,
+			version
 		}).then(() => {
-			expect(store.getState()).to.deep.equal(expectedStore);
+			expect(store.getState()).toEqual(expectedStore);
 		});
 	});
 
 	it('Add License Agreement', () => {
 		const store = storeCreator();
 		deepFreeze(store.getState());
-		const licenseAgreementPostRequest = {
-			name: 'name_ADDED_LA',
-			description: 'description_ADDED_LA',
-			licenseTerm: 'licenseTerm_ADDED_LA',
-			requirementsAndConstrains: 'req_and_constraints_ADDED_LA',
-			addedFeatureGroupsIds: []
-		};
-		deepFreeze(licenseAgreementPostRequest);
 
-		const licenseAgreementToAdd = {
-			name: 'name_ADDED_LA',
-			description: 'description_ADDED_LA',
-			licenseTerm: 'licenseTerm_ADDED_LA',
-			requirementsAndConstrains: 'req_and_constraints_ADDED_LA',
-			featureGroupsIds: []
-		};
-		deepFreeze(licenseAgreementToAdd);
+		const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build();
+
+		const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build(
+			pickBy(licenseAgreementToAdd, (val, key) => key !== 'featureGroupsIds')
+		);
+
+		deepFreeze(LicenseAgreementPostRequest);
 
 		const licenseAgreementIdFromResponse = 'ADDED_ID';
-		const licenseAgreementAfterAdd = {
+		const licenseAgreementAfterAdd = LicenseAgreementStoreFactory.build({
 			...licenseAgreementToAdd,
 			id: licenseAgreementIdFromResponse
-		};
+		});
 		deepFreeze(licenseAgreementAfterAdd);
 
 		const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementAfterAdd]);
 
-		mockRest.addHandler('create', ({options, data, baseUrl}) => {
-			expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`);
-			expect(data).to.deep.equal(licenseAgreementPostRequest);
-			expect(options).to.equal(undefined);
+		mockRest.addHandler('post', ({options, data, baseUrl}) => {
+			expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
+			expect(data).toEqual(LicenseAgreementPostRequest);
+			expect(options).toEqual(undefined);
 			return {
 				value: licenseAgreementIdFromResponse
 			};
@@ -136,23 +107,15 @@
 
 		return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
 			licenseAgreement: licenseAgreementToAdd,
-			licenseModelId: LICENSE_MODEL_ID
+			licenseModelId: LICENSE_MODEL_ID,
+			version
 		}).then(() => {
-			expect(store.getState()).to.deep.equal(expectedStore);
+			expect(store.getState()).toEqual(expectedStore);
 		});
 	});
 
 	it('Update License Agreement', () => {
-		const licenseAgreementList = [
-			{
-				id: '0',
-				name: 'name0',
-				description: 'description0',
-				licenseTerm: 'licenseTerm0',
-				requirementsAndConstrains: 'req_and_constraints0',
-				featureGroupsIds: ['77']
-			}
-		];
+		const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1, {featureGroupsIds: ['77']});
 		const store = storeCreator({
 			licenseModel: {
 				licenseAgreement: {
@@ -162,43 +125,40 @@
 		});
 		deepFreeze(store.getState());
 
-		const toBeUpdatedLicenseAgreementId = licenseAgreementList[0].id;
 		const previousLicenseAgreementData = licenseAgreementList[0];
+		const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id;
+		const oldFeatureGroupIds = previousLicenseAgreementData.featureGroupsIds;
 
-		const licenseAgreementUpdateData = {
-			...licenseAgreementList[0],
-			name: 'name_UPDATED',
-			description: 'description_UPDATED',
-			licenseTerm: 'licenseTerm_UPDATED_LA',
-			requirementsAndConstrains: 'req_and_constraints_UPDATED_LA',
-			featureGroupsIds: ['update_id_1', 'update_id_2']
-		};
+		const newFeatureGroupsIds = ['update_id_1', 'update_id_2'];
+
+		const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({
+			id: toBeUpdatedLicenseAgreementId,
+			featureGroupsIds: newFeatureGroupsIds
+		});
 		deepFreeze(licenseAgreementUpdateData);
 
-		const licenseAgreementPutRequest = {
-			name: 'name_UPDATED',
-			description: 'description_UPDATED',
-			licenseTerm: 'licenseTerm_UPDATED_LA',
-			requirementsAndConstrains: 'req_and_constraints_UPDATED_LA',
-			addedFeatureGroupsIds: ['update_id_1', 'update_id_2'],
-			removedFeatureGroupsIds: ['77']
-		};
-		deepFreeze(licenseAgreementPutRequest);
+		const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build({
+			addedFeatureGroupsIds: newFeatureGroupsIds,
+			removedFeatureGroupsIds: oldFeatureGroupIds
+		});
+
+		deepFreeze(LicenseAgreementPutFactoryRequest);
 
 		const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementUpdateData]);
 
-		mockRest.addHandler('save', ({data, options, baseUrl}) => {
-			expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeUpdatedLicenseAgreementId}`);
-			expect(data).to.deep.equal(licenseAgreementPutRequest);
-			expect(options).to.equal(undefined);
+		mockRest.addHandler('put', ({data, options, baseUrl}) => {
+			expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeUpdatedLicenseAgreementId}`);
+			expect(data).toEqual(LicenseAgreementPutFactoryRequest);
+			expect(options).toEqual(undefined);
 		});
 
 		return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
 			licenseModelId: LICENSE_MODEL_ID,
+			version,
 			previousLicenseAgreement: previousLicenseAgreementData,
 			licenseAgreement: licenseAgreementUpdateData
 		}).then(() => {
-			expect(store.getState()).to.deep.equal(expectedStore);
+			expect(store.getState()).toEqual(expectedStore);
 		});
 	});
 
