aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authordavsad <david.sadlier@est.tech>2021-08-23 05:54:13 +0100
committerDavid Sadlier <david.sadlier@est.tech>2021-08-23 23:09:40 +0000
commit38f534f4c7c425f49925dd2d3615729eba703130 (patch)
treefcf7b3d0430e83d1ebf769fa1d85ddabcc6eb46f /catalog-be
parente5b8482c4d2ceddf559da26e532fdbb95a593dc1 (diff)
Filter catalog in UI based on model
Issue-ID: SDC-3679 Signed-off-by: davsad <david.sadlier@est.tech> Change-Id: Icd0eeb13dbfb1cc27745c7adf6a3212210e00a4a
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java32
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java11
2 files changed, 29 insertions, 14 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
index f79650ddc7..f8028583b3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
@@ -19,22 +19,12 @@
*/
package org.openecomp.sdc.be.servlets;
-import com.jcabi.aspects.Loggable;
-import fj.data.Either;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.media.ArraySchema;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.servers.Server;
-import io.swagger.v3.oas.annotations.servers.Servers;
-import io.swagger.v3.oas.annotations.tags.Tags;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.inject.Inject;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -50,8 +40,10 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ElementBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ModelBusinessLogic;
import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
import org.openecomp.sdc.be.components.scheduledtasks.ComponentsCleanBusinessLogic;
@@ -83,6 +75,19 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Controller;
+import com.jcabi.aspects.Loggable;
+
+import fj.data.Either;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.servers.Server;
+import io.swagger.v3.oas.annotations.servers.Servers;
+import io.swagger.v3.oas.annotations.tags.Tags;
+
@Path("/v1/")
/**
*
@@ -101,15 +106,17 @@ public class ElementServlet extends BeGenericServlet {
private final ComponentsCleanBusinessLogic componentsCleanBusinessLogic;
private final ElementBusinessLogic elementBusinessLogic;
private final ArtifactsBusinessLogic artifactsBusinessLogic;
+ private final ModelBusinessLogic modelBusinessLogic;
@Inject
public ElementServlet(final UserBusinessLogic userBusinessLogic, final ComponentsUtils componentsUtils,
final ComponentsCleanBusinessLogic componentsCleanBusinessLogic, final ElementBusinessLogic elementBusinessLogic,
- final ArtifactsBusinessLogic artifactsBusinessLogic) {
+ final ArtifactsBusinessLogic artifactsBusinessLogic, final ModelBusinessLogic modelBusinessLogic) {
super(userBusinessLogic, componentsUtils);
this.componentsCleanBusinessLogic = componentsCleanBusinessLogic;
this.elementBusinessLogic = elementBusinessLogic;
this.artifactsBusinessLogic = artifactsBusinessLogic;
+ this.modelBusinessLogic = modelBusinessLogic;
}
/*
******************************************************************************
@@ -652,6 +659,7 @@ public class ElementServlet extends BeGenericServlet {
return buildErrorResponse(either.right().value());
}
consolidatedObject.put("categories", either.left().value());
+ consolidatedObject.put("models", modelBusinessLogic.listModels());
consolidatedObject.put("version", getVersion(servletContext));
} catch (Exception e) {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError("getSDCVersion");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
index c1837846f6..f4ca52b0c2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
@@ -28,11 +28,11 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
-import fj.data.Either;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -40,8 +40,10 @@ import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.apache.commons.text.StrSubstitutor;
import org.apache.http.HttpStatus;
+import org.assertj.core.util.Lists;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
@@ -54,6 +56,7 @@ import org.mockito.Mockito;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ElementBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ModelBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
@@ -89,6 +92,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.context.WebApplicationContext;
+import fj.data.Either;
+
class ElementServletTest extends JerseyTest {
public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
@@ -111,6 +116,7 @@ class ElementServletTest extends JerseyTest {
private static final ComponentsCleanBusinessLogic componentsCleanBusinessLogic = Mockito
.mock(ComponentsCleanBusinessLogic.class);
private static final ElementBusinessLogic elementBusinessLogic = Mockito.mock(ElementBusinessLogic.class);
+ private static final ModelBusinessLogic modelBusinessLogic = Mockito.mock(ModelBusinessLogic.class);
private static final ResponseFormat okResponseFormat = new ResponseFormat(HttpStatus.SC_OK);
private static final ResponseFormat conflictResponseFormat = new ResponseFormat(HttpStatus.SC_CONFLICT);
@@ -180,7 +186,7 @@ class ElementServletTest extends JerseyTest {
when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
when(webApplicationContext.getBean(ComponentsUtils.class)).thenReturn(componentUtils);
when(beGenericServlet.getComponentsUtils()).thenReturn(componentUtils);
-
+ when(modelBusinessLogic.listModels()).thenReturn(Lists.emptyList());
Either<User, ActionStatus> designerEither = Either.left(designerUser);
when(userAdmin.getUser(designerUser.getUserId(), false)).thenReturn(designerUser);
@@ -1101,6 +1107,7 @@ class ElementServletTest extends JerseyTest {
bind(componentsCleanBusinessLogic).to(ComponentsCleanBusinessLogic.class);
bind(elementBusinessLogic).to(ElementBusinessLogic.class);
bind(artifactsBusinessLogic).to(ArtifactsBusinessLogic.class);
+ bind(modelBusinessLogic).to(ModelBusinessLogic.class);
}
})
.property("contextConfig", context);