summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java6
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java85
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java48
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java50
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java109
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java42
6 files changed, 337 insertions, 3 deletions
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java
index f0fca86..c9d6dc8 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java
@@ -120,13 +120,13 @@ public abstract class DCAEServiceTransactionDAO {
}
@CreateSqlObject
- abstract DCAEServicesDAO getServicesDAO();
+ abstract public DCAEServicesDAO getServicesDAO();
@CreateSqlObject
- abstract DCAEServicesComponentsMapsDAO getServicesComponentsMappingDAO();
+ abstract public DCAEServicesComponentsMapsDAO getServicesComponentsMappingDAO();
@CreateSqlObject
- abstract DCAEServiceComponentsDAO getComponentsDAO();
+ abstract public DCAEServiceComponentsDAO getComponentsDAO();
@Transaction
public void insert(DCAEServiceTransactionContext context) {
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java b/src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java
new file mode 100644
index 0000000..2a909f4
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * 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.dcae.inventory.dbthings.daos;
+
+import org.joda.time.DateTime;
+import org.junit.Test;
+import org.openecomp.dcae.inventory.daos.DCAEServiceComponentsDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServiceTransactionDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServicesComponentsMapsDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Created by mhwang on 10/2/17.
+ */
+public class DCAEServiceTransactionDAOTests {
+
+ @Test
+ public void testCreateDCAEServiceTransactionContext() {
+ String serviceId = "service-foo";
+ DateTime modifiedTime = new DateTime();
+ DCAEServiceTransactionDAO.DCAEServiceTransactionContext context
+ = new DCAEServiceTransactionDAO.DCAEServiceTransactionContext(serviceId, modifiedTime);
+
+ assertEquals(context.getServiceId(), serviceId);
+ assertEquals(context.getModified(), modifiedTime);
+ }
+
+ @Test
+ public void testInsert() {
+ String serviceId = "service-foo";
+ DateTime modifiedTime = new DateTime();
+ DCAEServiceTransactionDAO.DCAEServiceTransactionContext context
+ = new DCAEServiceTransactionDAO.DCAEServiceTransactionContext(serviceId, modifiedTime);
+
+ DCAEServicesDAO servicesDAO = mock(DCAEServicesDAO.class);
+ DCAEServicesComponentsMapsDAO componentsMapsDAO = mock(DCAEServicesComponentsMapsDAO.class);
+ DCAEServiceComponentsDAO componentsDAO = mock(DCAEServiceComponentsDAO.class);
+
+ DCAEServiceTransactionDAO transactionDAO = new DCAEServiceTransactionDAO() {
+
+ public DCAEServicesDAO getServicesDAO() {
+ return servicesDAO;
+ }
+
+ public DCAEServicesComponentsMapsDAO getServicesComponentsMappingDAO() {
+ return componentsMapsDAO;
+ }
+
+ public DCAEServiceComponentsDAO getComponentsDAO() {
+ return componentsDAO;
+ }
+ };
+
+ try {
+ transactionDAO.insert(context);
+ assertTrue(true);
+ } catch(Exception e) {
+ fail("Unexpected error");
+ }
+
+ }
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java b/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java
new file mode 100644
index 0000000..cb3c7f1
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * 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.dcae.inventory.dbthings.mappers;
+
+import org.junit.Test;
+
+import java.sql.ResultSet;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Created by mhwang on 10/2/17.
+ */
+public class DCAEServiceComponentObjectMapperTests {
+
+ @Test
+ public void testMap() {
+ ResultSet resultSet = mock(ResultSet.class);
+ DCAEServiceComponentObjectMapper mapper = new DCAEServiceComponentObjectMapper();
+
+ try {
+ assertNotNull(mapper.map(0, resultSet, null));
+ } catch(Exception e) {
+ fail("Unexpected exception");
+ }
+ }
+
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java b/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java
new file mode 100644
index 0000000..1946343
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * 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.dcae.inventory.dbthings.mappers;
+
+import org.junit.Test;
+
+import java.sql.ResultSet;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Created by mhwang on 10/2/17.
+ */
+public class DCAEServiceObjectMapperTests {
+
+ @Test
+ public void testMap() {
+ ResultSet resultSet = mock(ResultSet.class);
+ DCAEServiceObjectMapper mapper = new DCAEServiceObjectMapper();
+
+ try {
+ when(resultSet.getString("status")).thenReturn("RUNNING");
+ assertNotNull(mapper.map(0, resultSet, null));
+ } catch(Exception e) {
+ fail("Unexpected exception");
+ }
+ }
+
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java b/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java
new file mode 100644
index 0000000..f8c2428
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * 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.dcae.inventory.dbthings.mappers;
+
+import org.junit.Test;
+
+import java.sql.Array;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+/**
+ * Created by mhwang on 10/2/17.
+ */
+public class DCAEServiceTypeObjectMapperTests {
+
+ @Test
+ public void testMap() {
+ ResultSet resultSet = mock(ResultSet.class);
+ DCAEServiceTypeObjectMapper mapper = new DCAEServiceTypeObjectMapper();
+
+ try {
+ when(resultSet.getArray(anyString())).thenReturn(new Array() {
+ @Override
+ public String getBaseTypeName() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public int getBaseType() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public Object getArray() throws SQLException {
+ return new String[10];
+ }
+
+ @Override
+ public Object getArray(Map<String, Class<?>> map) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Object getArray(long index, int count) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getResultSet() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getResultSet(long index, int count) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public void free() throws SQLException {
+
+ }
+ });
+ assertNotNull(mapper.map(0, resultSet, null));
+ } catch(Exception e) {
+ fail("Unexpected exception");
+ }
+ }
+
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java b/src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java
new file mode 100644
index 0000000..083b237
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * 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.dcae.inventory.providers;
+
+import io.swagger.api.NotFoundException;
+import org.junit.Test;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by mhwang on 10/2/17.
+ */
+public class NotFoundExceptionMapperTests {
+
+ @Test
+ public void testNotFoundExceptionMapper() {
+ NotFoundExceptionMapper mapper = new NotFoundExceptionMapper();
+ Response response = mapper.toResponse(new NotFoundException(100, "Some error message"));
+ assertEquals(response.getStatus(), 404);
+ }
+
+}