aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src
diff options
context:
space:
mode:
authorTomasz Golabek <tomasz.golabek@nokia.com>2019-06-25 14:30:23 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-07-14 11:55:00 +0000
commit5bb0a3b09bfe2c7f12af05af83223501c29a3f76 (patch)
tree9e7f3acdc5ad70111289b5c81baa4d9ffc86c222 /catalog-dao/src
parentff5db76f909826b332bcf294752646ed65ffaae5 (diff)
ComponentCache & ComponentCassandraDao removal
Also removed all classes uses these two. Change-Id: I6793c3c935ae61c5c65f70d3541c542edf188ab4 Issue-ID: SDC-2389 Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'catalog-dao/src')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java47
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java254
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java1
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java97
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java153
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDaoTest.java409
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescriptionTest.java92
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ComponentCacheDataTest.java197
8 files changed, 0 insertions, 1250 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
deleted file mode 100644
index dcdd390485..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
+++ /dev/null
@@ -1,47 +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.dao.cassandra;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Param;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.sdc.be.resources.data.ComponentCacheData;
-
-import java.util.List;
-
-@Accessor
-public interface ComponentCacheAccessor {
-
- @Query("SELECT * FROM sdccomponent.componentcache WHERE id IN :ids ALLOW FILTERING")
- Result<ComponentCacheData> getComponents(@Param("ids") List<String> ids);
-
- @Query("SELECT * FROM sdccomponent.componentcache WHERE id = :id ALLOW FILTERING")
- Result<ComponentCacheData> getComponent(@Param("id") String id);
-
- @Query("SELECT id,modification_time,type FROM sdccomponent.componentcache ALLOW FILTERING")
- Result<ComponentCacheData> getAllComponentIdTimeAndType();
-
- // @Query("SELECT * FROM sdcartifact.resources LIMIT 2000")
- // Result<ESArtifactData> getListOfResources();
-
- // Result<ESArtifactData> getListOfResources(List<String> dids);
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
deleted file mode 100644
index 7b23a9db41..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
+++ /dev/null
@@ -1,254 +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.dao.cassandra;
-
-import com.datastax.driver.core.Session;
-import com.datastax.driver.mapping.MappingManager;
-import com.datastax.driver.mapping.Result;
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.resources.data.ComponentCacheData;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Component("component-cassandra-dao")
-public class ComponentCassandraDao extends CassandraDao {
-
- private static Logger logger = Logger.getLogger(ComponentCassandraDao.class.getName());
-
- public final static Integer DEFAULT_FETCH_SIZE = 500;
-
- private ComponentCacheAccessor componentCacheAccessor;
-
-
- @Autowired
- public ComponentCassandraDao(CassandraClient cassandraClient) {
- super(cassandraClient);
- }
-
- @PostConstruct
- public void init() {
- String keyspace = AuditingTypesConstants.COMPONENT_KEYSPACE;
- if (client.isConnected()) {
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
- if (result.isLeft()) {
- session = result.left().value().left;
- manager = result.left().value().right;
- componentCacheAccessor = manager.createAccessor(ComponentCacheAccessor.class);
- logger.info("** ComponentCassandraDao created");
- } else {
- logger.info("** ComponentCassandraDao failed");
- throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : "
- + result.right().value());
- }
- } else {
- logger.info("** Cassandra client isn't connected");
- logger.info("** ComponentCassandraDao created, but not connected");
- }
- }
-
- /**
- *
- * @param ids
- * - list of components unique id
- * @return
- */
- public Either<List<ComponentCacheData>, ActionStatus> getComponents(List<String> ids) {
-
- List<ComponentCacheData> components = new ArrayList<>();
- if (ids == null || ids.isEmpty()) {
- return Either.left(components);
- }
-
- try {
-
- Result<ComponentCacheData> events = componentCacheAccessor.getComponents(ids);
- if (events == null) {
- logger.trace("not found component for ids list of in size {}", ids.size());
- return Either.left(components);
- }
- events.all().forEach(event -> {
- components.add(event);
- logger.trace("Fetch component uid = {} isDirty = {}", event.getId(), event.getIsDirty());
- });
-
- logger.debug("Number of components to fetch was {}. Actually, {} components fetched", ids.size(),
- components.size());
-
- return Either.left(components);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentsFromCache");
-
- logger.debug("failed to get components from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ComponentCacheData>, ActionStatus> getAllComponentIdTimeAndType() {
- try {
- List<ComponentCacheData> components = new ArrayList<>();
- Result<ComponentCacheData> events = componentCacheAccessor.getAllComponentIdTimeAndType();
- if (events == null) {
- logger.trace("no component found ");
- return Either.left(components);
- }
- events.all().forEach(event -> {
- components.add(event);
- logger.trace("Fetch component uid = {} isDirty = {}", event.getId(), event.getIsDirty());
- });
-
- logger.debug("Number of components fetched was {}.", components.size());
-
- return Either.left(components);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentsFromCache");
-
- logger.debug("failed to get components from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- /**
- *
- * @param id
- * - component unique id
- * @return
- */
- public Either<ComponentCacheData, ActionStatus> getComponent(String id) {
-
- if (id == null) {
- return Either.right(ActionStatus.INVALID_CONTENT);
- }
-
- try {
-
- Result<ComponentCacheData> events = componentCacheAccessor.getComponent(id);
- if (events == null) {
- logger.trace("not found component for id {}", id);
- return Either.right(ActionStatus.RESOURCE_NOT_FOUND);
- }
-
- ComponentCacheData componentCacheData = events.one();
- if (componentCacheData != null) {
- logger.debug("Component with id {} was found. isDirty={}.", componentCacheData.getId(),
- componentCacheData.getIsDirty());
- } else {
- return Either.right(ActionStatus.RESOURCE_NOT_FOUND);
- }
- return Either.left(componentCacheData);
-
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentFromCache");
-
- logger.trace("Failed to get component from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public CassandraOperationStatus saveComponent(ComponentCacheData componentCacheData) {
- return client.save(componentCacheData, ComponentCacheData.class, manager);
- }
-
- /**
- * the method checks if the given table is empty in the artifact keyspace
- *
- * @param tableName
- * the name of the table we want to check
- * @return true if the table is empty
- */
- public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
- return super.isTableEmpty(tableName);
- }
-
- /**
- *
- * @param idToTimestampMap
- * - list of components unique id
- * @return
- */
- public Either<ImmutablePair<List<ComponentCacheData>, Set<String>>, ActionStatus> getComponents(
- Map<String, Long> idToTimestampMap) {
-
- List<ComponentCacheData> components = new ArrayList<>();
- Set<String> notFetchedFromCache = new HashSet<>();
- ImmutablePair<List<ComponentCacheData>, Set<String>> result = new ImmutablePair<>(
- components, notFetchedFromCache);
-
- if (idToTimestampMap == null || idToTimestampMap.isEmpty()) {
- return Either.left(result);
- }
-
- try {
-
- Set<String> keySet = idToTimestampMap.keySet();
- List<String> ids = new ArrayList<>();
- ids.addAll(keySet);
- Result<ComponentCacheData> events = componentCacheAccessor.getComponents(ids);
- if (events == null) {
- logger.trace("not found component for ids list of in size {}", ids.size());
- notFetchedFromCache.addAll(idToTimestampMap.keySet());
- return Either.left(result);
- }
- events.all().forEach(event -> {
- long timeFromCache = event.getModificationTime().getTime();
- long timeRequested = idToTimestampMap.get(event.getId());
- if (timeFromCache == timeRequested) {
- logger.trace("Fetch component uid = {} from cache", event.getId());
- components.add(event);
- } else {
- logger.trace(
- "Fetch and ignore component uid = {} from cache. Time requested is {} while timestamp in cache is {}",
- event.getId(), timeRequested, timeFromCache);
- }
- });
-
- logger.debug("Number of components to fetch was {}. Actually, {} components fetched", ids.size(),
- components.size());
- List<String> foundComponents = components.stream().map(ComponentCacheData::getId).collect(Collectors.toList());
- // fetch all ids which was not found in cache/found in cache and not
- // updated.
- Set<String> notFoundComponents = idToTimestampMap.keySet().stream()
- .filter(p -> !foundComponents.contains(p)).collect(Collectors.toSet());
-
- notFetchedFromCache.addAll(notFoundComponents);
-
- return Either.left(result);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentsFromCache");
-
- logger.debug("failed to get components from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public CassandraOperationStatus deleteComponent(String id) {
- return client.delete(id, ComponentCacheData.class, manager);
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
index 2e4a6329aa..b0209d2a13 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
@@ -40,7 +40,6 @@ public enum Table {
GET_USERS_LIST_EVENT(new GetUsersListEventTableDesc()),
GET_CATEGORY_HIERARCHY_EVENT(new GetCatHierEventTableDesc()),
EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()),
- COMPONENT_CACHE(new ComponentCacheTableDescription()),
SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription()),
SDC_REPO(new MigrationTasksTableDescription()),
SDC_OPERATIONAL_ENVIRONMENT(new OperationalEnvironmentsTableDescription()),
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java
deleted file mode 100644
index cb13e0ea15..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java
+++ /dev/null
@@ -1,97 +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.dao.cassandra.schema.tables;
-
-import com.datastax.driver.core.DataType;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ComponentCacheTableDescription implements ITableDescription {
-
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(ID_FIELD, DataType.varchar()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (PartialComponentFieldsDescription field : PartialComponentFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.COMPONENT_KEYSPACE;
- }
-
- @Override
- public String getTableName() {
- return "componentcache";
- }
-
- enum PartialComponentFieldsDescription {
- DATA("data", DataType.blob(), false),
- MODIFICATION_TIME("modification_time", DataType.timestamp(), false),
- TYPE("type", DataType.varchar(), false),
- IS_DIRTY("is_dirty", DataType.cboolean(), false),
- IS_ZIPPED("is_zipped", DataType.cboolean(), false),;
-
- private String name;
- private DataType type;
- private boolean indexed;
-
- PartialComponentFieldsDescription(String name, DataType type, boolean indexed) {
- this.name = name;
- this.type = type;
- this.indexed = indexed;
- }
-
- public String getName() {
- return name;
- }
-
- public DataType getType() {
- return type;
- }
-
- public boolean isIndexed() {
- return indexed;
- }
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- return null;
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
deleted file mode 100644
index cb7af866be..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
+++ /dev/null
@@ -1,153 +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.data;
-
-import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.PartitionKey;
-import com.datastax.driver.mapping.annotations.Table;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-@Table(keyspace = "sdccomponent", name = "componentcache")
-public class ComponentCacheData {
- public final static String RRESOURCE_ID_FIELD = "resourceId";
-
- public final static String SERVICE_NAME_FIELD = "serviceName";
- public final static String SERVICE_VERSION_FIELD = "serviceVersion";
- public final static String ARTIFACT_NAME_FIELD = "artifactName";
-
- public final static String delim = ":";
-
- @PartitionKey
- @Column(name = "id")
- private String id;
-
- @Column
- private ByteBuffer data;
-
- @Column(name = "modification_time")
- private Date modificationTime;
-
- @Column
- private String type;
-
- @Column(name = "is_dirty")
- private boolean isDirty;
-
- @Column(name = "is_zipped")
- private boolean isZipped;
-
- public ComponentCacheData() {
-
- }
-
- public ComponentCacheData(String id, byte[] data, Date modificationTime, String type, boolean isDirty,
- boolean isZipped) {
- super();
- this.id = id;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- }
- this.modificationTime = modificationTime;
- this.type = type;
- this.isDirty = isDirty;
- this.isZipped = isZipped;
- }
-
- public ComponentCacheData(String id) {
-
- this.id = id;
- }
-
- public ComponentCacheData(String artifactId, byte[] data) {
- super();
- this.id = artifactId;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- // this.data = data.clone();
- }
- }
-
- public byte[] getDataAsArray() {
- if (data != null) {
- return data.array();
- }
- return null;
- }
-
- public void setDataAsArray(byte[] data) {
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- }
- }
-
- public ByteBuffer getData() {
- return data;
- }
-
- public void setData(ByteBuffer data) {
- if (data != null) {
- this.data = data.duplicate();
- }
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Date getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Date modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public boolean getIsDirty() {
- return isDirty;
- }
-
- public void setIsDirty(boolean isDirty) {
- this.isDirty = isDirty;
- }
-
- public boolean getIsZipped() {
- return isZipped;
- }
-
- public void setIsZipped(boolean isZipped) {
- this.isZipped = isZipped;
- }
-
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDaoTest.java
deleted file mode 100644
index 564ee5ae08..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDaoTest.java
+++ /dev/null
@@ -1,409 +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.dao.cassandra;
-
-import com.datastax.driver.core.Session;
-import com.datastax.driver.mapping.MappingManager;
-import com.datastax.driver.mapping.Result;
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-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.ActionStatus;
-import org.openecomp.sdc.be.resources.data.ComponentCacheData;
-
-import java.util.*;
-
-import static org.junit.Assert.assertTrue;
-
-public class ComponentCassandraDaoTest {
-
- @InjectMocks
- ComponentCassandraDao testSubject;
-
- @Mock
- CassandraClient clientMock;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testInit() throws Exception {
-
- // default test
- testSubject.init();
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- testSubject.init();
- }
-
- @Test
- public void testInitException() throws Exception {
-
- // default test
- testSubject.init();
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either
- .right(CassandraOperationStatus.CLUSTER_NOT_CONNECTED);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- try {
- testSubject.init();
- } catch (Exception e) {
- assertTrue(e.getClass() == RuntimeException.class);
- }
- }
-
- @Test
- public void testGetComponents() throws Exception {
- List<String> ids;
- Either<List<ComponentCacheData>, ActionStatus> result;
-
- // test 1
- ids = null;
- result = testSubject.getComponents(ids);
-
-
- // test 2
- ids = new LinkedList<>();
- result = testSubject.getComponents(ids);
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Result<ComponentCacheData> value2 = Mockito.mock(Result.class);
- Mockito.when(componentCacheAccessorMock.getComponents(Mockito.any())).thenReturn(value2);
- List<ComponentCacheData> value3 = new LinkedList<>();
- value3.add(new ComponentCacheData("mock"));
- Mockito.when(value2.all()).thenReturn(value3);
- testSubject.init();
-
- ids.add("mock");
- testSubject.getComponents(ids);
- }
-
- @Test
- public void testGetComponentsNull() throws Exception {
- List<String> ids = new LinkedList<>();
- Either<List<ComponentCacheData>, ActionStatus> result;
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Mockito.when(componentCacheAccessorMock.getComponents(Mockito.any())).thenReturn(null);
- testSubject.init();
-
- ids.add("mock");
- testSubject.getComponents(ids);
- }
-
- @Test
- public void testGetComponentsException() throws Exception {
- List<String> ids = new LinkedList<>();
- Either<List<ComponentCacheData>, ActionStatus> result;
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Mockito.when(componentCacheAccessorMock.getComponents(Mockito.any())).thenThrow(RuntimeException.class);
- testSubject.init();
-
- ids.add("mock");
- testSubject.getComponents(ids);
- }
-
- @Test
- public void testGetAllComponentIdTimeAndType() throws Exception {
- Either<List<ComponentCacheData>, ActionStatus> result;
-
- // default test
- result = testSubject.getAllComponentIdTimeAndType();
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Result<ComponentCacheData> value2 = Mockito.mock(Result.class);
- Mockito.when(componentCacheAccessorMock.getAllComponentIdTimeAndType()).thenReturn(value2);
- List<ComponentCacheData> value3 = new LinkedList<>();
- value3.add(new ComponentCacheData("mock"));
- Mockito.when(value2.all()).thenReturn(value3);
- testSubject.init();
-
- testSubject.getAllComponentIdTimeAndType();
- }
-
- @Test
- public void testGetAllComponentIdTimeAndTypeNull() throws Exception {
- Either<List<ComponentCacheData>, ActionStatus> result;
-
- // default test
- result = testSubject.getAllComponentIdTimeAndType();
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Mockito.when(componentCacheAccessorMock.getAllComponentIdTimeAndType()).thenReturn(null);
- testSubject.init();
-
- result = testSubject.getAllComponentIdTimeAndType();
- }
-
- @Test
- public void testGetComponent() throws Exception {
- String id = "";
- Either<ComponentCacheData, ActionStatus> result;
-
- // test 1
- id = null;
- result = testSubject.getComponent(id);
- //Assert.assertEquals(null, result);
-
- // test 2
- id = "";
- result = testSubject.getComponent(id);
- //Assert.assertEquals(null, result);
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Result<ComponentCacheData> value2 = Mockito.mock(Result.class);
- Mockito.when(componentCacheAccessorMock.getComponent(Mockito.any())).thenReturn(value2);
- ComponentCacheData value3 = new ComponentCacheData();
- Mockito.when(value2.one()).thenReturn(value3);
- testSubject.init();
-
- result = testSubject.getComponent(id);
- }
-
- @Test
- public void testGetComponentNull1() throws Exception {
- String id = "";
- Either<ComponentCacheData, ActionStatus> result;
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Mockito.when(componentCacheAccessorMock.getComponent(Mockito.any())).thenReturn(null);
- testSubject.init();
-
- result = testSubject.getComponent(id);
- }
-
- @Test
- public void testGetComponentNull2() throws Exception {
- String id = "";
- Either<ComponentCacheData, ActionStatus> result;
-
- // test 1
- id = null;
- result = testSubject.getComponent(id);
- //Assert.assertEquals(null, result);
-
- // test 2
- id = "";
- result = testSubject.getComponent(id);
- //Assert.assertEquals(null, result);
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Result<ComponentCacheData> value2 = Mockito.mock(Result.class);
- Mockito.when(componentCacheAccessorMock.getComponent(Mockito.any())).thenReturn(value2);
- Mockito.when(value2.one()).thenReturn(null);
- testSubject.init();
-
- result = testSubject.getComponent(id);
- }
-
- @Test
- public void testSaveComponent() throws Exception {
- ComponentCacheData componentCacheData = null;
- CassandraOperationStatus result;
-
- // default test
- result = testSubject.saveComponent(componentCacheData);
- }
-
- @Test
- public void testIsTableEmpty() throws Exception {
- String tableName = "";
- Either<Boolean, CassandraOperationStatus> result;
-
- // default test
- result = testSubject.isTableEmpty(tableName);
- }
-
- @Test
- public void testGetComponents_1() throws Exception {
- Map<String, Long> idToTimestampMap = null;
- Either<ImmutablePair<List<ComponentCacheData>, Set<String>>, ActionStatus> result;
-
- // test 1
- idToTimestampMap = null;
- result = testSubject.getComponents(idToTimestampMap);
- //Assert.assertEquals(null, result);
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Result<ComponentCacheData> value2 = Mockito.mock(Result.class);
- Mockito.when(componentCacheAccessorMock.getComponents(Mockito.any(List.class))).thenReturn(value2);
- List<ComponentCacheData> value3 = new LinkedList<>();
- ComponentCacheData e = new ComponentCacheData("mock");
- Mockito.when(value2.all()).thenReturn(value3);
- testSubject.init();
-
- idToTimestampMap = new HashMap<>();
- idToTimestampMap.put("mock", 0L);
- e.setModificationTime(new Date());
- value3.add(e);
- result = testSubject.getComponents(idToTimestampMap);
- }
-
- @Test
- public void testGetComponents_1Null() throws Exception {
- Map<String, Long> idToTimestampMap = null;
- Either<ImmutablePair<List<ComponentCacheData>, Set<String>>, ActionStatus> result;
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Mockito.when(componentCacheAccessorMock.getComponents(Mockito.any(List.class))).thenReturn(null);
- testSubject.init();
-
- idToTimestampMap = new HashMap<>();
- idToTimestampMap.put("mock", 0L);
- result = testSubject.getComponents(idToTimestampMap);
- }
-
- @Test
- public void testGetComponents_1Exception() throws Exception {
- Map<String, Long> idToTimestampMap = null;
- Either<ImmutablePair<List<ComponentCacheData>, Set<String>>, ActionStatus> result;
-
- Session sessMock = Mockito.mock(Session.class);
- MappingManager mappMock = Mockito.mock(MappingManager.class);
- ComponentCacheAccessor componentCacheAccessorMock = Mockito.mock(ComponentCacheAccessor.class);
- ImmutablePair<Session, MappingManager> ipMock = ImmutablePair.of(sessMock, mappMock);
-
- Mockito.when(clientMock.isConnected()).thenReturn(true);
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> value = Either.left(ipMock);
- Mockito.when(clientMock.connect(Mockito.any())).thenReturn(value);
- Mockito.when(mappMock.createAccessor(ComponentCacheAccessor.class)).thenReturn(componentCacheAccessorMock);
-
- Mockito.when(componentCacheAccessorMock.getComponents(Mockito.any(List.class))).thenThrow(RuntimeException.class);
- testSubject.init();
-
- idToTimestampMap = new HashMap<>();
- idToTimestampMap.put("mock", 0L);
- result = testSubject.getComponents(idToTimestampMap);
- }
-
- @Test
- public void testDeleteComponent() throws Exception {
- String id = "";
- CassandraOperationStatus result;
-
- // default test
- result = testSubject.deleteComponent(id);
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescriptionTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescriptionTest.java
deleted file mode 100644
index 4968bb6603..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescriptionTest.java
+++ /dev/null
@@ -1,92 +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.dao.cassandra.schema.tables;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.junit.Test;
-
-import com.datastax.driver.core.DataType;
-
-
-public class ComponentCacheTableDescriptionTest {
-
- private ComponentCacheTableDescription createTestSubject() {
- return new ComponentCacheTableDescription();
- }
-
-
- @Test
- public void testPrimaryKeys() throws Exception {
- ComponentCacheTableDescription testSubject;
- List<ImmutablePair<String, DataType>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.primaryKeys();
- }
-
-
- @Test
- public void testGetColumnDescription() throws Exception {
- ComponentCacheTableDescription testSubject;
- Map<String, ImmutablePair<DataType, Boolean>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getColumnDescription();
- }
-
-
- @Test
- public void testGetKeyspace() throws Exception {
- ComponentCacheTableDescription testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getKeyspace();
- }
-
-
- @Test
- public void testGetTableName() throws Exception {
- ComponentCacheTableDescription testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTableName();
- }
-
-
- @Test
- public void testClusteringKeys() throws Exception {
- ComponentCacheTableDescription testSubject;
- List<ImmutablePair<String, DataType>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.clusteringKeys();
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ComponentCacheDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ComponentCacheDataTest.java
deleted file mode 100644
index 54bfa502b5..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ComponentCacheDataTest.java
+++ /dev/null
@@ -1,197 +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;
-import java.util.Date;
-
-
-public class ComponentCacheDataTest {
-
- private ComponentCacheData createTestSubject() {
- return new ComponentCacheData();
- }
-
- @Test
- public void testCtor() throws Exception {
- new ComponentCacheData("mock");
- new ComponentCacheData("mock", new byte[0]);
- new ComponentCacheData("mock", new byte[0], new Date(), "mock", true, true);
- }
-
- @Test
- public void testGetDataAsArray() throws Exception {
- ComponentCacheData testSubject;
- byte[] result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDataAsArray();
- }
-
-
- @Test
- public void testSetDataAsArray() throws Exception {
- ComponentCacheData 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 {
- ComponentCacheData testSubject ;
-
- testSubject = createTestSubject();
-
- testSubject.getData();
- }
-
- @Test
- public void testSetData() throws Exception {
- ComponentCacheData testSubject ;
-
- testSubject = createTestSubject();
-
- ByteBuffer data = ByteBuffer.allocate(0);
- testSubject.setData(data);
- }
-
- @Test
- public void testGetId() throws Exception {
- ComponentCacheData testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
-
- @Test
- public void testSetId() throws Exception {
- ComponentCacheData testSubject;
- String id = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setId(id);
- }
-
-
- @Test
- public void testGetModificationTime() throws Exception {
- ComponentCacheData testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModificationTime();
- }
-
-
- @Test
- public void testSetModificationTime() throws Exception {
- ComponentCacheData testSubject;
- Date modificationTime = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setModificationTime(modificationTime);
- }
-
-
- @Test
- public void testGetType() throws Exception {
- ComponentCacheData testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getType();
- }
-
-
- @Test
- public void testSetType() throws Exception {
- ComponentCacheData testSubject;
- String type = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setType(type);
- }
-
-
- @Test
- public void testGetIsDirty() throws Exception {
- ComponentCacheData testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getIsDirty();
- }
-
-
- @Test
- public void testSetIsDirty() throws Exception {
- ComponentCacheData testSubject;
- boolean isDirty = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIsDirty(isDirty);
- }
-
-
- @Test
- public void testGetIsZipped() throws Exception {
- ComponentCacheData testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getIsZipped();
- }
-
-
- @Test
- public void testSetIsZipped() throws Exception {
- ComponentCacheData testSubject;
- boolean isZipped = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIsZipped(isZipped);
- }
-}