Raise JUnit coverage common-be
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / servlets / GroupTypesEndpoint.java
1 package org.openecomp.sdc.be.servlets;
2
3 import java.util.List;
4
5 import javax.ws.rs.Consumes;
6 import javax.ws.rs.GET;
7 import javax.ws.rs.HeaderParam;
8 import javax.ws.rs.Path;
9 import javax.ws.rs.Produces;
10 import javax.ws.rs.QueryParam;
11 import javax.ws.rs.core.MediaType;
12
13 import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
14 import org.openecomp.sdc.be.mixin.GroupTypeMixin;
15 import org.openecomp.sdc.be.model.GroupTypeDefinition;
16 import org.openecomp.sdc.be.view.ResponseView;
17 import org.openecomp.sdc.common.api.Constants;
18 import org.springframework.stereotype.Controller;
19
20 import com.jcabi.aspects.Loggable;
21
22 import io.swagger.annotations.Api;
23 import io.swagger.annotations.ApiOperation;
24 import io.swagger.annotations.ApiParam;
25 import io.swagger.annotations.ApiResponse;
26 import io.swagger.annotations.ApiResponses;
27
28 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
29 @Path("/v1/catalog")
30 @Api(value = "group types resource")
31 @Controller
32 @Consumes(MediaType.APPLICATION_JSON)
33 @Produces(MediaType.APPLICATION_JSON)
34 public class GroupTypesEndpoint {
35
36     private final GroupTypeBusinessLogic groupTypeBusinessLogic;
37
38     public GroupTypesEndpoint(GroupTypeBusinessLogic groupTypeBusinessLogic) {
39         this.groupTypeBusinessLogic = groupTypeBusinessLogic;
40     }
41
42     @GET
43     @Path("/groupTypes")
44     @ApiOperation(value = "Get group types ", httpMethod = "GET", notes = "Returns group types", response = GroupTypeDefinition.class, responseContainer = "List")
45     @ApiResponses(value = {
46             @ApiResponse(code = 200, message = "group types found"),
47             @ApiResponse(code = 400, message = "field name invalid type/length, characters;  mandatory field is absent, already exists (name)"),
48             @ApiResponse(code = 403, message = "Restricted operation"),
49             @ApiResponse(code = 500, message = "Internal Error")
50     })
51     @ResponseView(mixin = {GroupTypeMixin.class})
52     public List<GroupTypeDefinition> getGroupTypes(@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
53                                                    @ApiParam(value = "An optional parameter to indicate the type of the container from where this call is executed")
54                                                    @QueryParam("internalComponentType") String internalComponentType) {
55         return groupTypeBusinessLogic.getAllGroupTypes(userId, internalComponentType);
56     }
57
58 }