summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test/java/org/openecomp/sdc/be/resources
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao/src/test/java/org/openecomp/sdc/be/resources')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java134
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/AuditingDaoTest.java445
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ConsumerDataTest.java95
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ESArtifactDataTest.java105
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ProductMetadataDataTest.java3
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ResourceMetadataDataTest.java3
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceArtifactsDataCollectionTest.java67
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceMetadataDataTest.java11
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEventTest.java8
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEventTest.java2
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEventTest.java103
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java61
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/impl/ResourceUploaderTest.java249
13 files changed, 122 insertions, 1164 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java
deleted file mode 100644
index dc65d5d236..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*-
- * ============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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources;
-
-import fj.data.Either;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.api.IGenericSearchDAO;
-import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
-import org.openecomp.sdc.be.resources.api.IResourceUploader;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-import org.openecomp.sdc.be.utils.DAOConfDependentTest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestExecutionListeners;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
-import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
-import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
-
-import javax.annotation.Resource;
-
-import static org.junit.Assert.*;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:application-context-test.xml")
-@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class,
- DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class }) // ,
- // CassandraUnitTestExecutionListener.class})
-public class ArtifactDaoTest extends DAOConfDependentTest {
- private static final String TEST_IMAGES_DIRECTORY = "src/test/resources/images";
-
- @Resource
- ElasticSearchClient esclient;
-
- @Resource(name = "resource-upload")
- private IResourceUploader daoUploader;
- ESArtifactData arData;
-
- @Resource(name = "resource-dao")
- private IGenericSearchDAO resourceDAO;
-
- private String nodeTypeVersion = "1.0.0";
-
- private static ConfigurationManager configurationManager;
-
- @Test
- public void testSaveNewArtifact() {
- // daoUploader = new ArtifactUploader(artifactDAO);
- if (daoUploader == null) {
- assertTrue(false);
- }
- String strData = "qweqwqweqw34e4wrwer";
-
- String myNodeType = "MyNewNodeType";
-
- ESArtifactData arData = new ESArtifactData("artifactNewMarina11", strData.getBytes());
-
- ResourceUploadStatus status = daoUploader.saveArtifact(arData, true);
-
- assertEquals(status, ResourceUploadStatus.OK);
-
- daoUploader.deleteArtifact(arData.getId());
-
- }
-
- @Test
- public void testGetArtifact() {
-
- String myNodeType = "MyNodeType";
-
- // resourceDAO.save(indexedNodeType);
- ESArtifactData arData = getArtifactData(myNodeType, nodeTypeVersion);
-
- ESArtifactData getData = null;
- Either<ESArtifactData, ResourceUploadStatus> getArtifactStatus = daoUploader
- .getArtifact(myNodeType + "- dassasd" + ":" + nodeTypeVersion + ":updatedArtifact");
- if (getArtifactStatus.isRight()) {
- daoUploader.saveArtifact(arData, true);
- getArtifactStatus = daoUploader.getArtifact(arData.getId());
- }
- assertNotNull(getArtifactStatus.left().value());
-
- }
-
-
- @Test
- public void testUpdateArtifact() {
- if (daoUploader == null) {
- fail();
- }
- ResourceUploadStatus status = ResourceUploadStatus.OK;
-
- String myNodeType = "MyUpdatedNodeType";
-
- ESArtifactData arData = getArtifactData(myNodeType, nodeTypeVersion);
- Either<ESArtifactData, ResourceUploadStatus> getArtifactStatus = daoUploader.getArtifact(arData.getId());
-
- if (!getArtifactStatus.isLeft())
- status = daoUploader.saveArtifact(arData, false);
-
- String payload1 = "new payloadjfdsgh";
- arData.setDataAsArray(payload1.getBytes());
-
- status = daoUploader.updateArtifact(arData);
-
- assertEquals(status, ResourceUploadStatus.OK);
- }
-
- private ESArtifactData getArtifactData(String componentName, String componentVersion) {
- String strData = "qweqwqweqw34e4wrwer";
-
- return new ESArtifactData("updatedArtifact", strData.getBytes());
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/AuditingDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/AuditingDaoTest.java
deleted file mode 100644
index 919c69fce4..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/AuditingDaoTest.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*-
- * ============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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources;
-
-import fj.data.Either;
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.index.query.MatchAllQueryBuilder;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.SearchHits;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openecomp.sdc.be.config.Configuration;
-import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig.IndicesTimeFrequencyEntry;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
-import org.openecomp.sdc.be.dao.impl.AuditingDao;
-import org.openecomp.sdc.be.resources.data.auditing.*;
-import org.openecomp.sdc.be.utils.DAOConfDependentTest;
-import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import org.openecomp.sdc.common.datastructure.ESTimeBasedEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestExecutionListeners;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
-import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
-import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import static org.junit.Assert.*;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:application-context-test.xml")
-@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class,
- DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class })
-public class AuditingDaoTest extends DAOConfDependentTest{
- private static Logger log = LoggerFactory.getLogger(AuditingDaoTest.class.getName());
- @Resource(name = "elasticsearch-client")
- private ElasticSearchClient esclient;
-
- @Resource(name = "auditingDao")
- private AuditingDao auditingDao;
-
- @After
- public void tearDown() {
- deleteOldIndexes();
- }
-
- @Before
- public void setup() {
- auditingDao.setConfigurationManager(configurationManager);
- deleteOldIndexes();
- }
-
- private void deleteOldIndexes() {
- DeleteIndexResponse deleteResponse = esclient.getClient().admin().indices()
- .prepareDelete(auditingDao.getIndexPrefix() + "*").execute().actionGet();
- if (!deleteResponse.isAcknowledged()) {
- log.debug("Couldn't delete old auditing indexes!");
- fail();
- }
- }
-
- // @Test
- public void testAddUpdateAdminEventMinute() {
-
- String timestamp = "2015-06-23 13:34:53.123";
-
- String creationPeriod = Constants.MINUTE;
- String expectedIndexName = auditingDao.getIndexPrefix() + "-2015-06-23-13-34";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName).execute().actionGet()
- .isExists());
- Map<AuditingFieldsKey, Object> params = getUserAdminEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAdminEvent.class);
- params = getUserAccessEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAccessEvent.class);
- params = getResourceAdminEventParams(timestamp, "addResource");
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, ResourceAdminEvent.class);
- }
-
- // @Test
- public void testAddUpdateAdminEventYearly() {
-
- String timestamp = "2016-06-23 13:34:53.123";
- String creationPeriod = Constants.YEAR;
- String expectedIndexName = auditingDao.getIndexPrefix() + "-2016";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName).execute().actionGet()
- .isExists());
- Map<AuditingFieldsKey, Object> params = getUserAdminEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAdminEvent.class);
- params = getUserAccessEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAccessEvent.class);
- params = getResourceAdminEventParams(timestamp, "addResource");
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, ResourceAdminEvent.class);
- }
-
- @Test
- public void testGetDistributionStatusEvent() {
-
- String timestamp1 = "2016-06-23 13:34:53.123";
- String creationPeriod = Constants.MONTH;
- String expectedIndexName1 = auditingDao.getIndexPrefix() + "-2016-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName1).execute().actionGet()
- .isExists());
- Map<AuditingFieldsKey, Object> params = getDistributionStatusEventParams(timestamp1);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName1, DistributionStatusEvent.class);
- String timestamp2 = "2015-06-23 13:34:53.123";
-
- String expectedIndexName2 = auditingDao.getIndexPrefix() + "-2015-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName2).execute().actionGet()
- .isExists());
- Map<AuditingFieldsKey, Object> params2 = getDistributionStatusEventParams(timestamp2);
- testCreationPeriodScenario(params2, creationPeriod, expectedIndexName2, DistributionStatusEvent.class);
- Either<List<ESTimeBasedEvent>, ActionStatus> status = auditingDao.getListOfDistributionStatuses("123-456");
- assertEquals(2, status.left().value().size());
- }
-
- @Test
- public void testGetCountAdminEventMonthly() {
-
- String timestamp1 = "2016-06-23 13:34:53.123";
- String timestamp2 = "2015-06-23 13:34:53.123";
- String creationPeriod = Constants.MONTH;
- String expectedIndexName1 = auditingDao.getIndexPrefix() + "-2016-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName1).execute().actionGet()
- .isExists());
- String expectedIndexName2 = auditingDao.getIndexPrefix() + "-2015-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName2).execute().actionGet()
- .isExists());
-
- Map<AuditingFieldsKey, Object> params1 = getUserAdminEventParams(timestamp1);
- testCreationPeriodScenario(params1, creationPeriod, expectedIndexName1, UserAdminEvent.class);
- Map<AuditingFieldsKey, Object> params2 = getUserAdminEventParams(timestamp2);
- testCreationPeriodScenario(params2, creationPeriod, expectedIndexName2, UserAdminEvent.class);
-
- long count = auditingDao.count(UserAdminEvent.class, new MatchAllQueryBuilder());
- log.debug("Testing auditing count {}", count);
- assertEquals(2, count);
- }
-
- @Test
- public void testServiceDistributionStatuses() {
-
- String timestamp = "2016-06-23 13:34:53.123";
- String creationPeriod = Constants.MONTH;
- String expectedIndexName = auditingDao.getIndexPrefix() + "-2016-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName).execute().actionGet()
- .isExists());
- Map<AuditingFieldsKey, Object> params = getUserAdminEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAdminEvent.class);
- params = getUserAccessEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAccessEvent.class);
- params = getResourceAdminEventParams(timestamp, "DRequest");
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, ResourceAdminEvent.class);
- params = getDistributionNotificationEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, DistributionNotificationEvent.class);
- Either<List<ESTimeBasedEvent>, ActionStatus> status = auditingDao
- .getServiceDistributionStatusesList("SeviceId");
- log.debug("Testing auditing count {}", status);
- }
-
- @Test
- public void testAddUpdateAdminEventMonthly() {
-
- String timestamp = "2016-06-23 13:34:53.123";
- String creationPeriod = Constants.MONTH;
- String expectedIndexName = auditingDao.getIndexPrefix() + "-2016-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName).execute().actionGet()
- .isExists());
- Map<AuditingFieldsKey, Object> params = getUserAdminEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAdminEvent.class);
- params = getUserAccessEventParams(timestamp);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, UserAccessEvent.class);
- params = getResourceAdminEventParams(timestamp, "addResource");
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, ResourceAdminEvent.class);
- }
-
- @Test
- public void testGetFilteredResourceAdminAuditingEvents() {
- Map<AuditingFieldsKey, Object> filterMap = new HashMap<>();
- filterMap.put(AuditingFieldsKey.AUDIT_ACTION, new Object());
- Either<List<ESTimeBasedEvent>, ActionStatus> filteredResourceAdminAuditingEvents = auditingDao
- .getFilteredResourceAdminAuditingEvents(filterMap);
- }
-
- @Test
- public void testGetListOfDistributionByAction() {
- Either<List<ESTimeBasedEvent>, ActionStatus> filteredResourceAdminAuditingEvents = auditingDao
- .getListOfDistributionByAction("mock", "mock", "mock", AuditingGenericEvent.class);
- filteredResourceAdminAuditingEvents = auditingDao
- .getListOfDistributionByAction("mock", "mock", null, AuditingGenericEvent.class);
- }
-
- private SearchResponse testCreationPeriodScenario(Map<AuditingFieldsKey, Object> params, String creationPeriod,
- String expectedIndexName, Class<? extends AuditingGenericEvent> clazz) {
-
- String typeName = clazz.getSimpleName().toLowerCase();
- log.debug("Testing auditing type {}", typeName);
- setCreationPeriod(creationPeriod);
- ActionStatus saveUserAdminEvent = auditingDao.addRecord(params, typeName);
- assertEquals(ActionStatus.OK, saveUserAdminEvent);
- assertTrue(esclient.getClient().admin().indices().prepareExists(expectedIndexName).execute().actionGet()
- .isExists());
- MatchAllQueryBuilder matchAllQueryBuilder = new MatchAllQueryBuilder();
-
- SearchResponse searchResponse = esclient.getClient().prepareSearch(expectedIndexName).setTypes(typeName)
- .setQuery(matchAllQueryBuilder).execute().actionGet();
-
- SearchHits hits = searchResponse.getHits();
- assertEquals(1, hits.getTotalHits());
- log.debug("Checking that all expected fields are properly persisted");
- validateHitValues(params, hits.getAt(0));
- log.debug("testCreationPeriodScenario successful");
- return searchResponse;
- }
-
- private void validateHitValues(Map<AuditingFieldsKey, Object> params, SearchHit searchHit) {
- Map<String, Object> source = searchHit.getSource();
- log.debug("Hit source is {}", searchHit.sourceAsString());
- for (Entry<AuditingFieldsKey, Object> paramsEntry : params.entrySet()) {
- AuditingFieldsKey key = paramsEntry.getKey();
- log.debug("Testing auditing field {}", key.name());
- Object value = paramsEntry.getValue();
- // assertEquals(value, source.get(auditField2esField.get(key)));
- assertEquals(value, source.get(key.getDisplayName()));
- }
- }
-
- private void setCreationPeriod(String creationPeriod) {
- Configuration configuration = configurationManager.getConfiguration();
- List<IndicesTimeFrequencyEntry> indicesTimeFrequencyEntries = new ArrayList<>();
- IndicesTimeFrequencyEntry indicesTimeFrequencyEntry = new IndicesTimeFrequencyEntry();
- indicesTimeFrequencyEntry.setIndexPrefix("auditingevents");
- indicesTimeFrequencyEntry.setCreationPeriod(creationPeriod);
- configuration.getElasticSearch().setIndicesTimeFrequency(indicesTimeFrequencyEntries);
- }
-
- private Map<AuditingFieldsKey, Object> getUserAdminEventParams(String timestamp) {
-
- Map<AuditingFieldsKey, Object> params = new HashMap<>();
- String action = "updateUser";
- String modifierName = "moshe moshe";
- String modifierUid = "mosheUid";
- String userUid = "mosheUid";
- String userBeforeName = "moshe moshe";
- String userBeforeEmail = "moshe@moshe1.com";
- String userBeforeRole = "TESTER";
- String userAfterName = "moshe moshe";
- String userAfterEmail = "moshe@moshe2.com";
- String userAfterRole = "TESTER";
- String userStatus = "200";
- String userDesc = "OK";
-
- params.put(AuditingFieldsKey.AUDIT_ACTION, action);
- params.put(AuditingFieldsKey.AUDIT_MODIFIER_UID, modifierName + '(' + modifierUid + ')');
- params.put(AuditingFieldsKey.AUDIT_USER_UID, userUid);
- params.put(AuditingFieldsKey.AUDIT_USER_BEFORE,
- userUid + ", " + userBeforeName + ", " + userBeforeEmail + ", " + userBeforeRole);
- params.put(AuditingFieldsKey.AUDIT_USER_AFTER,
- userUid + ", " + userAfterName + ", " + userAfterEmail + ", " + userAfterRole);
- params.put(AuditingFieldsKey.AUDIT_STATUS, userStatus);
- params.put(AuditingFieldsKey.AUDIT_DESC, userDesc);
- params.put(AuditingFieldsKey.AUDIT_TIMESTAMP, timestamp);
-
- return params;
- }
-
- private Map<AuditingFieldsKey, Object> getUserAccessEventParams(String timestamp) {
-
- Map<AuditingFieldsKey, Object> params = new HashMap<>();
- String action = "userAccess";
- String userUid = "mosheUid";
- String userName = "moshe moshe";
- String userStatus = "200";
- String userDesc = "OK";
-
- params.put(AuditingFieldsKey.AUDIT_ACTION, action);
- params.put(AuditingFieldsKey.AUDIT_USER_UID, userName + '(' + userUid + ')');
- params.put(AuditingFieldsKey.AUDIT_STATUS, userStatus);
- params.put(AuditingFieldsKey.AUDIT_DESC, userDesc);
- params.put(AuditingFieldsKey.AUDIT_TIMESTAMP, timestamp);
-
- return params;
- }
-
- private Map<AuditingFieldsKey, Object> getResourceAdminEventParams(String timestamp, String action) {
-
- Map<AuditingFieldsKey, Object> params = new HashMap<>();
-
- String modifierName = "moshe moshe";
- String modifierUid = "mosheUid";
- String resourceName = "Centos";
- String resourceType = "Resource";
- String currState = "READY_FOR_CERTIFICATION";
- String prevState = "CHECKED_OUT";
- String currVersion = "1.1.4";
- String prevVersion = "1.1.3";
- String status = "200";
- String desc = "OK";
- String distributionId = "123-456";
- String serviceId = "SeviceId";
-
- params.put(AuditingFieldsKey.AUDIT_ACTION, action);
- params.put(AuditingFieldsKey.AUDIT_MODIFIER_NAME, modifierName);
- params.put(AuditingFieldsKey.AUDIT_MODIFIER_UID, modifierUid);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, resourceName);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE, resourceType);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE, currState);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_STATE, prevState);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION, currVersion);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_VERSION, prevVersion);
- params.put(AuditingFieldsKey.AUDIT_STATUS, status);
- params.put(AuditingFieldsKey.AUDIT_DESC, desc);
- params.put(AuditingFieldsKey.AUDIT_TIMESTAMP, timestamp);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID, distributionId);
- params.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID, serviceId);
-
- return params;
- }
-
- private Map<AuditingFieldsKey, Object> getDistributionStatusEventParams(String timestamp) {
-
- Map<AuditingFieldsKey, Object> params = new HashMap<>();
- String action = "DStatus";
- String modifierName = "moshe moshe";
- String modifierUid = "mosheUid";
- String topicName = "Centos";
- String serviceId = "SeviceId";
- String resourceUrl = "resourceUrl";
- String distributionId = "123-456";
-
- String status = "200";
- String desc = "OK";
-
- params.put(AuditingFieldsKey.AUDIT_DESC, desc);
- params.put(AuditingFieldsKey.AUDIT_TIMESTAMP, timestamp);
- params.put(AuditingFieldsKey.AUDIT_STATUS, status);
- params.put(AuditingFieldsKey.AUDIT_ACTION, action);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID, distributionId);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID, modifierUid);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME, topicName);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL, resourceUrl);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME, timestamp);
- params.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID, serviceId);
-
- return params;
- }
-
- // @Test
- public void getListOfDistributionByActionTest() {
-
- String timestamp = "2016-06-23 13:34:53.123";
- String distributionId = "123-456";
-
- String creationPeriod = Constants.MONTH;
- String expectedIndexName = auditingDao.getIndexPrefix() + "-2016-06";
- assertTrue(!esclient.getClient().admin().indices().prepareExists(expectedIndexName).execute().actionGet()
- .isExists());
-
- Map<AuditingFieldsKey, Object> params = getResourceAdminEventParams(timestamp, "DRequest");
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID, distributionId);
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, ResourceAdminEvent.class);
- params = getDistributionNotificationEventParams(timestamp);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID, distributionId);
-
- testCreationPeriodScenario(params, creationPeriod, expectedIndexName, DistributionNotificationEvent.class);
-
- Either<List<ESTimeBasedEvent>, ActionStatus> distributionByAction = auditingDao
- .getListOfDistributionByAction(distributionId, "DRequest", "200", ResourceAdminEvent.class);
- assertTrue(distributionByAction.isLeft());
- assertFalse(distributionByAction.left().value().isEmpty());
-
- distributionByAction = auditingDao.getListOfDistributionByAction(distributionId, "DNotify", "200",
- DistributionNotificationEvent.class);
- assertTrue(distributionByAction.isLeft());
- assertFalse(distributionByAction.left().value().isEmpty());
-
- }
-
- private Map<AuditingFieldsKey, Object> getDistributionNotificationEventParams(String timestamp) {
-
- Map<AuditingFieldsKey, Object> params = new HashMap<>();
-
- String action = "DNotify";
- String modifierName = "moshe moshe";
- String modifierUid = "mosheUid";
- String resourceName = "Centos";
- String resourceType = "Resource";
-
- String currVersion = "1.1.4";
- String currState = "READY_FOR_CERTIFICATION";
- String status = "200";
- String desc = "OK";
- String did = "1027";
- String topicName = "Centos";
- String serviceId = "SeviceId";
- String requestId = "12364";
-
- params.put(AuditingFieldsKey.AUDIT_ACTION, action);
- params.put(AuditingFieldsKey.AUDIT_MODIFIER_NAME, requestId);
- params.put(AuditingFieldsKey.AUDIT_MODIFIER_UID, modifierUid);
- params.put(AuditingFieldsKey.AUDIT_MODIFIER_NAME, modifierName);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, resourceName);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE, resourceType);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE, currState);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME, topicName);
- params.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION, currVersion);
- params.put(AuditingFieldsKey.AUDIT_STATUS, status);
- params.put(AuditingFieldsKey.AUDIT_DESC, desc);
- params.put(AuditingFieldsKey.AUDIT_TIMESTAMP, timestamp);
- params.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID, did);
- params.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID, serviceId);
- return params;
- }
-
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ConsumerDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ConsumerDataTest.java
deleted file mode 100644
index 591f118c7c..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ConsumerDataTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources.data;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class ConsumerDataTest {
-
- private ConsumerData createTestSubject() {
- return new ConsumerData();
- }
-
- @Test
- public void testCtor() throws Exception {
- new ConsumerData(new ConsumerDataDefinition());
- new ConsumerData(new HashMap<>());
- }
-
- @Test
- public void testGetUniqueIdKey() throws Exception {
- ConsumerData testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUniqueIdKey();
- }
-
-
- @Test
- public void testGetUniqueId() throws Exception {
- ConsumerData testSubject;
- Object result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUniqueId();
- }
-
-
- @Test
- public void testGetConsumerDataDefinition() throws Exception {
- ConsumerData testSubject;
- ConsumerDataDefinition result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getConsumerDataDefinition();
- }
-
-
- @Test
- public void testToGraphMap() throws Exception {
- ConsumerData testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toGraphMap();
- }
-
-
- @Test
- public void testToString() throws Exception {
- ConsumerData testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ESArtifactDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ESArtifactDataTest.java
deleted file mode 100644
index 8dd407f506..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ESArtifactDataTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources.data;
-
-import org.junit.Test;
-
-import java.nio.ByteBuffer;
-
-public class ESArtifactDataTest {
-
- private ESArtifactData createTestSubject() {
- return new ESArtifactData();
- }
-
- @Test
- public void testCtor() throws Exception {
- new ESArtifactData("mock");
- new ESArtifactData("mock", new byte[0]);
- }
-
- @Test
- public void testGetDataAsArray() throws Exception {
- ESArtifactData testSubject;
- byte[] result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDataAsArray();
- }
-
- @Test
- public void testSetDataAsArray() throws Exception {
- ESArtifactData testSubject;
- byte[] data = new byte[] { ' ' };
-
- // test 1
- testSubject = createTestSubject();
- data = null;
- testSubject.setDataAsArray(data);
-
- // test 2
- testSubject = createTestSubject();
- data = new byte[] { ' ' };
- testSubject.setDataAsArray(data);
- }
-
- @Test
- public void testGetData() throws Exception {
- ESArtifactData testSubject;
- ByteBuffer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getData();
- }
-
- @Test
- public void testSetData() throws Exception {
- ESArtifactData testSubject;
- ByteBuffer data = null;
-
- // test 1
- testSubject = createTestSubject();
- data = null;
- testSubject.setData(data);
- }
-
- @Test
- public void testGetId() throws Exception {
- ESArtifactData testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
- @Test
- public void testSetId() throws Exception {
- ESArtifactData testSubject;
- String id = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setId(id);
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ProductMetadataDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ProductMetadataDataTest.java
index 2663125d7a..66b55b4302 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ProductMetadataDataTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ProductMetadataDataTest.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.resources.data;
import org.junit.Test;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.elements.ProductMetadataDataDefinition;
import java.util.HashMap;
@@ -36,7 +37,7 @@ public class ProductMetadataDataTest {
@Test
public void testCtor() throws Exception {
new ProductMetadataData(new ProductMetadataDataDefinition());
- new ProductMetadataData(new HashMap<>());
+ new ProductMetadataData(new GraphPropertiesDictionaryExtractor(new HashMap<>()));
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ResourceMetadataDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ResourceMetadataDataTest.java
index faaa491bac..9723f24c51 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ResourceMetadataDataTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ResourceMetadataDataTest.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.resources.data;
import org.junit.Test;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import java.util.HashMap;
@@ -35,7 +36,7 @@ public class ResourceMetadataDataTest {
@Test
public void testCtor() throws Exception {
new ResourceMetadataData(new ResourceMetadataDataDefinition());
- new ResourceMetadataData(new HashMap<>());
+ new ResourceMetadataData(new GraphPropertiesDictionaryExtractor(new HashMap<>()));
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceArtifactsDataCollectionTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceArtifactsDataCollectionTest.java
deleted file mode 100644
index fd61d54b80..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceArtifactsDataCollectionTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources.data;
-
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-
-public class ServiceArtifactsDataCollectionTest {
-
- private ServiceArtifactsDataCollection createTestSubject() {
- return new ServiceArtifactsDataCollection();
- }
-
-
- @Test
- public void testGetServiceArtifactDataMap() throws Exception {
- ServiceArtifactsDataCollection testSubject;
- Map<String, List<ESArtifactData>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServiceArtifactDataMap();
- }
-
-
- @Test
- public void testSetServiceArtifactDataMap() throws Exception {
- ServiceArtifactsDataCollection testSubject;
- Map<String, List<ESArtifactData>> serviceArtifactDataMap = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServiceArtifactDataMap(serviceArtifactDataMap);
- }
-
-
- @Test
- public void testGetNodeTemplateArtifacts() throws Exception {
- ServiceArtifactsDataCollection testSubject;
- String nodeTemplateName = "";
- List<ESArtifactData> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNodeTemplateArtifacts(nodeTemplateName);
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceMetadataDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceMetadataDataTest.java
index 104c762d8c..ac51bfdaa6 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceMetadataDataTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceMetadataDataTest.java
@@ -21,7 +21,12 @@
package org.openecomp.sdc.be.resources.data;
import org.junit.Test;
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
import java.util.HashMap;
import java.util.Map;
@@ -29,13 +34,17 @@ import java.util.Map;
public class ServiceMetadataDataTest {
+ private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+ "src/test/resources/config/catalog-dao");
+ private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+
private ServiceMetadataData createTestSubject() {
return new ServiceMetadataData();
}
@Test
public void testCtor() throws Exception {
- new ServiceMetadataData(new HashMap());
+ new ServiceMetadataData(new GraphPropertiesDictionaryExtractor(new HashMap<>()));
new ServiceMetadataData(new ServiceMetadataDataDefinition());
}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEventTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEventTest.java
index ec19b9a6ce..8cdbe3ec73 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEventTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEventTest.java
@@ -117,7 +117,7 @@ public class DistributionStatusEventTest {
@Test
- public void testGetResoureURL() throws Exception {
+ public void testGetResourceURL() throws Exception {
DistributionStatusEvent testSubject;
String result;
@@ -128,13 +128,13 @@ public class DistributionStatusEventTest {
@Test
- public void testSetResoureURL() throws Exception {
+ public void testSetResourceURL() throws Exception {
DistributionStatusEvent testSubject;
- String resoureURL = "";
+ String resourceURL = "";
// default test
testSubject = createTestSubject();
- testSubject.setResoureURL(resoureURL);
+ testSubject.setResoureURL(resourceURL);
}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEventTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEventTest.java
index 1d99a01536..bbf8627e42 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEventTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEventTest.java
@@ -113,7 +113,7 @@ public class EcompOperationalEnvironmentEventTest {
// default test
testSubject = createTestSubject();
- testSubject.setOperational_environment_type(operationalEnvironmentType);
+ testSubject.setOperationalEnvironmentType(operationalEnvironmentType);
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEventTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEventTest.java
new file mode 100644
index 0000000000..53bf27d9f9
--- /dev/null
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEventTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.sdc.be.resources.data.togglz;
+
+import org.junit.Test;
+import org.togglz.core.repository.FeatureState;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.isEmptyOrNullString;
+import static org.hamcrest.Matchers.isEmptyString;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+public class FeatureToggleEventTest {
+ private final String strategyId = "123456";
+ private final String param1 = "param1";
+ private final String param1Value = "param1Value";
+ private final String param2 = "param2";
+ private final String param2Value = "param2Value";
+
+ @Test
+ public void createEventFromFeatureStateObject() {
+ final String param3 = "param3";
+ final String param3Value = "param3Value";
+ final String responseParams = "param3=param3Value,param1=param1Value,param2=param2Value";
+
+
+ FeatureState featureState = new FeatureState(ToggleableFeature.DEFAULT_FEATURE, true);
+ featureState.setStrategyId(strategyId)
+ .setParameter(param1, param1Value)
+ .setParameter(param2, param2Value)
+ .setParameter(param3, param3Value);
+
+ FeatureToggleEvent featureToggleEvent = new FeatureToggleEvent(featureState);
+ assertThat(featureToggleEvent.getEnabled(), is("true"));
+ assertThat(featureToggleEvent.getStrategyId(), is(strategyId));
+ assertThat(featureToggleEvent.getParameters(), is(responseParams));
+ }
+
+ @Test
+ public void createEventWhenStrategyIsNotSetAndStateIsFalse() {
+ FeatureState featureState = new FeatureState(ToggleableFeature.DEFAULT_FEATURE, false);
+
+ FeatureToggleEvent featureToggleEvent = new FeatureToggleEvent(featureState);
+ assertThat(featureToggleEvent.getEnabled(), is("false"));
+ assertThat(featureToggleEvent.getParameters(), isEmptyString());
+ assertThat(featureToggleEvent.getStrategyId(), isEmptyOrNullString());
+ }
+
+ @Test
+ public void getFeatureStateObjectFromEventWithNoParams() {
+ FeatureState featureState = new FeatureState(ToggleableFeature.DEFAULT_FEATURE, true);
+ FeatureToggleEvent featureToggleEvent = new FeatureToggleEvent(featureState);
+ FeatureState fromEvent = featureToggleEvent.getFeatureState();
+ assertThat(ToggleableFeature.DEFAULT_FEATURE, is(fromEvent.getFeature()));
+ assertThat(fromEvent.isEnabled(), is(true));
+ assertThat(fromEvent.getParameterMap().size(), is(0));
+ assertThat(fromEvent.getStrategyId(), nullValue());
+ }
+
+ @Test
+ public void getFeatureStateObjectFromEventWithParams() {
+ FeatureState featureState = new FeatureState(ToggleableFeature.DEFAULT_FEATURE, true);
+ featureState.setStrategyId(strategyId)
+ .setParameter(param1, param1Value)
+ .setParameter(param2, param2Value);
+ FeatureToggleEvent featureToggleEvent = new FeatureToggleEvent(featureState);
+ FeatureState fromEvent = featureToggleEvent.getFeatureState();
+ assertThat(fromEvent.getFeature(), is(ToggleableFeature.DEFAULT_FEATURE));
+ assertThat(fromEvent.isEnabled(), is(true));
+ assertThat(fromEvent.getStrategyId(), is(strategyId));
+ assertThat(fromEvent.getParameterMap().size(), is(2));
+ assertThat(fromEvent.getParameterMap().get(param1), is(param1Value));
+ assertThat(fromEvent.getParameterMap().get(param2), is(param2Value));
+ }
+
+ @Test
+ public void getFeatureStateObjectFromEventWhenStateIsWrong() {
+ FeatureState featureState = new FeatureState(ToggleableFeature.DEFAULT_FEATURE, true);
+ FeatureToggleEvent featureToggleEvent = new FeatureToggleEvent(featureState);
+ featureToggleEvent.setFeatureName("wrong");
+ assertThat(featureToggleEvent.getFeatureState(), nullValue());
+ }
+
+}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java
deleted file mode 100644
index 4ea58818e1..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources.exception;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
-
-
-public class ResourceDAOExceptionTest {
-
- private ResourceDAOException createTestSubject() {
- return new ResourceDAOException("", null);
- }
-
- @Test
- public void testCtor() throws Exception {
- new ResourceDAOException("mock");
- new ResourceDAOException("mock", new Throwable());
- new ResourceDAOException(ResourceUploadStatus.ALREADY_EXIST, "mock");
- new ResourceDAOException(ResourceUploadStatus.ALREADY_EXIST, "mock", new Throwable());
- }
-
- @Test
- public void testGetStatus() throws Exception {
- ResourceDAOException testSubject;
- ResourceUploadStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getStatus();
- }
-
-
- @Test
- public void testSetStatus() throws Exception {
- ResourceDAOException testSubject;
- ResourceUploadStatus status = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setStatus(status);
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/impl/ResourceUploaderTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/impl/ResourceUploaderTest.java
deleted file mode 100644
index 71e52f9df2..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/impl/ResourceUploaderTest.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.openecomp.sdc.be.resources.impl;
-
-import fj.data.Either;
-import mockit.Deencapsulation;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.be.dao.api.ICatalogDAO;
-import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-import org.openecomp.sdc.be.resources.exception.ResourceDAOException;
-import org.openecomp.sdc.be.utils.DAOConfDependentTest;
-
-public class ResourceUploaderTest extends DAOConfDependentTest{
-
- @InjectMocks
- ResourceUploader testSubject;
-
- @Mock
- ICatalogDAO resourceDAO;
-
- @Before
- public void setUpMocks() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testCtor() throws Exception {
- new ResourceUploader();
- ICatalogDAO resourcetDAO = Mockito.mock(ICatalogDAO.class);
- new ResourceUploader(resourcetDAO);
- }
-
- @Test
- public void testInit() throws Exception {
- // default test
- testSubject.init();
- }
-
- @Test
- public void testGetResourceDAO() throws Exception {
- ICatalogDAO result;
-
- // default test
- result = testSubject.getResourceDAO();
- }
-
- @Test
- public void testSetResourceDAO() throws Exception {
- ICatalogDAO resourceDAO = null;
-
- // default test
- testSubject.setResourceDAO(resourceDAO);
- }
-
- @Test
- public void testSaveArtifact() throws Exception {
- ESArtifactData artifactData = new ESArtifactData();
- artifactData.setId("mock");
- boolean isReload = false;
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.left(new ESArtifactData());
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
-
- // default test
- result = testSubject.saveArtifact(artifactData, isReload);
- }
-
- @Test
- public void testSaveArtifact2() throws Exception {
- ESArtifactData artifactData = new ESArtifactData();
- artifactData.setId("mock");
- boolean isReload = true;
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.left(new ESArtifactData());
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
-
- // default test
- result = testSubject.saveArtifact(artifactData, isReload);
- }
-
- @Test
- public void testSaveArtifactFailed() throws Exception {
- ESArtifactData artifactData = new ESArtifactData();
- artifactData.setId("mock");
- boolean isReload = false;
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.right(ResourceUploadStatus.ALREADY_EXIST);
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
-
- // default test
- result = testSubject.saveArtifact(artifactData, isReload);
- }
-
- @Test
- public void testSaveArtifactFailedException() throws Exception {
- ESArtifactData artifactData = new ESArtifactData();
- artifactData.setId("mock");
- boolean isReload = false;
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.right(ResourceUploadStatus.ALREADY_EXIST);
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
- Mockito.doThrow(new ResourceDAOException("mock")).when(resourceDAO).writeArtifact(Mockito.any());
-
- // default test
- result = testSubject.saveArtifact(artifactData, isReload);
- }
-
- @Test
- public void testSaveArtifactFailedDAONull() throws Exception {
- ESArtifactData artifactData = new ESArtifactData();
- boolean isReload = false;
- ResourceUploadStatus result;
-
- // default test
- ResourceUploader resourceUploader = new ResourceUploader(null);
- result = resourceUploader.saveArtifact(artifactData, isReload);
- }
-
- @Test
- public void testUpdateArtifact() throws Exception {
- ESArtifactData artifactUpdateData = new ESArtifactData();
- artifactUpdateData.setId("mock");
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.left(new ESArtifactData());
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
-
- // default test
- result = testSubject.updateArtifact(artifactUpdateData);
- }
-
- @Test
- public void testUpdateArtifactNotFound() throws Exception {
- ESArtifactData artifactUpdateData = new ESArtifactData();
- artifactUpdateData.setId("mock");
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.right(ResourceUploadStatus.NOT_EXIST);
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
-
- // default test
- result = testSubject.updateArtifact(artifactUpdateData);
- }
-
- @Test
- public void testUpdateArtifactException() throws Exception {
- ESArtifactData artifactUpdateData = new ESArtifactData();
- artifactUpdateData.setId("mock");
- ResourceUploadStatus result;
-
- Either<ESArtifactData, ResourceUploadStatus> value = Either.left(new ESArtifactData());
- Mockito.when(resourceDAO.getArtifact(Mockito.anyString())).thenReturn(value);
- Mockito.doThrow(new ResourceDAOException("mock")).when(resourceDAO).writeArtifact(Mockito.any());
-
- // default test
- result = testSubject.updateArtifact(artifactUpdateData);
- }
-
- @Test
- public void testUpdateArtifactDAONull() throws Exception {
- ESArtifactData artifactUpdateData = new ESArtifactData();
- ResourceUploadStatus result;
-
- // default test
- ResourceUploader resourceUploader = new ResourceUploader();
- result = resourceUploader.updateArtifact(artifactUpdateData);
- }
-
- @Test
- public void testGetArtifact() throws Exception {
- String id = "";
- Either<ESArtifactData, ResourceUploadStatus> result;
-
- // default test
- result = testSubject.getArtifact(id);
- }
-
- @Test
- public void testGetArtifactNull() throws Exception {
- String id = "";
- Either<ESArtifactData, ResourceUploadStatus> result;
-
- // default test
- ResourceUploader resourceUploader = new ResourceUploader();
- result = resourceUploader.getArtifact(id);
- }
-
- @Test
- public void testDeleteArtifact() throws Exception {
- String id = "";
-
- // default test
- testSubject.deleteArtifact(id);
- }
-
- @Test
- public void testUpdateArtifact_1() throws Exception {
- ESArtifactData artifactUpdateData = new ESArtifactData();
- ESArtifactData existData = new ESArtifactData();
- ResourceUploadStatus result;
-
- // default test
- result = Deencapsulation.invoke(testSubject, "updateArtifact",
- artifactUpdateData, existData);
- }
-
- @Test
- public void testUpdateData() throws Exception {
- ESArtifactData artifactUpdateData = new ESArtifactData();
- ESArtifactData existData = new ESArtifactData();
-
- // default test
- Deencapsulation.invoke(testSubject, "updateData", artifactUpdateData, existData);
- }
-
- @Test
- public void testDeleteAllArtifacts() throws Exception {
- // default test
- testSubject.deleteAllArtifacts();
- }
-}