import 정리

This commit is contained in:
현성필
2024-05-07 14:39:54 +09:00
parent ac88b6388e
commit c3afff535a
79 changed files with 294 additions and 254 deletions
@@ -2,13 +2,12 @@ package com.eactive.testmaster.client.controller;
import com.eactive.testmaster.server.entity.Server;
import com.eactive.testmaster.server.repository.ServerRepository;
import java.util.List;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@Controller
public class ApiClientPageController {
@@ -12,12 +12,14 @@ import com.eactive.testmaster.client.service.ApiRequestMgmtService;
import com.eactive.testmaster.common.util.SecurityUtil;
import com.eactive.testmaster.user.entity.StaffUser;
import com.eactive.testmaster.user.service.UserService;
import javax.transaction.Transactional;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.transaction.Transactional;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApiRequestMgmtController {
@@ -7,11 +7,14 @@ import com.eactive.testmaster.client.service.ApiScenarioMgmtService;
import com.eactive.testmaster.common.util.SecurityUtil;
import com.eactive.testmaster.user.entity.StaffUser;
import com.eactive.testmaster.user.service.UserService;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mgmt/api_scenario")
@@ -1,8 +1,8 @@
package com.eactive.testmaster.client.dto;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotEmpty;
public class ApiCollectionDTO {
@@ -1,6 +1,5 @@
package com.eactive.testmaster.client.dto;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -253,60 +252,60 @@ public class ApiLayoutItemTreeBuilder {
return siblings.get(closestIndex);
}
public static void main(String[] args) {
ApiLayoutItemDTO root = new ApiLayoutItemDTO();
root.setId(1L);
root.setLoutName("ROOT");
root.setLoutItemDepth(0);
root.setChildren(new ArrayList<>(List.of(
new ApiLayoutItemDTO(2L, 1L, "Field", "Child 2", 1, 10, "TEST11"),
new ApiLayoutItemDTO(3L, 1L, "Group", "Child 3", 1, 0, ""),
new ApiLayoutItemDTO(4L, 1L, "Field", "Child 4", 1, 10, "TEST21"),
new ApiLayoutItemDTO(5L, 1L, "Field", "Child 5", 1, 10, "TEST22"),
// new ApiLayoutItemDTO(6L, 1L, "Group", "Child 6", 1, 0, ""),
new ApiLayoutItemDTO(7L, 1L, "Field", "Child 7", 1, 10, "TEST31"),
new ApiLayoutItemDTO(8L, 1L, "Field", "Child 8", 1, 10, "TEST33"),
new ApiLayoutItemDTO(9L, 1L, "Group", "Child 9", 1, 0, ""),
new ApiLayoutItemDTO(10L, 1L, "Field", "Child 10", 1, 10, "TEST31"),
new ApiLayoutItemDTO(11L, 1L, "Field", "Child 11", 1, 10, "TEST33")
)));
for (ApiLayoutItemDTO item : root.getChildren()) {
item.setChildOccCnt(1);
}
System.out.println("Before moving:");
printTree(root);
moveNodeDepth(root, getNodeById(root, 4L), getNodeById(root, 4L).getLoutItemDepth() + 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 5L), getNodeById(root, 5L).getLoutItemDepth() + 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 7L), getNodeById(root, 7L).getLoutItemDepth() + 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 8L), getNodeById(root, 8L).getLoutItemDepth() + 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 10L), getNodeById(root, 10L).getLoutItemDepth() + 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 11L), getNodeById(root, 11L).getLoutItemDepth() + 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 9L), getNodeById(root, 9L).getLoutItemDepth() + 1);
printTree(root);
// moveNodeDepth(root, getNodeById(root, 6L), getNodeById(root, 6L).getLoutItemDepth() + 1);
// public static void main(String[] args) {
// ApiLayoutItemDTO root = new ApiLayoutItemDTO();
// root.setId(1L);
// root.setLoutName("ROOT");
// root.setLoutItemDepth(0);
// root.setChildren(new ArrayList<>(List.of(
// new ApiLayoutItemDTO(2L, 1L, "Field", "Child 2", 1, 10, "TEST11"),
// new ApiLayoutItemDTO(3L, 1L, "Group", "Child 3", 1, 0, ""),
// new ApiLayoutItemDTO(4L, 1L, "Field", "Child 4", 1, 10, "TEST21"),
// new ApiLayoutItemDTO(5L, 1L, "Field", "Child 5", 1, 10, "TEST22"),
//// new ApiLayoutItemDTO(6L, 1L, "Group", "Child 6", 1, 0, ""),
// new ApiLayoutItemDTO(7L, 1L, "Field", "Child 7", 1, 10, "TEST31"),
// new ApiLayoutItemDTO(8L, 1L, "Field", "Child 8", 1, 10, "TEST33"),
// new ApiLayoutItemDTO(9L, 1L, "Group", "Child 9", 1, 0, ""),
// new ApiLayoutItemDTO(10L, 1L, "Field", "Child 10", 1, 10, "TEST31"),
// new ApiLayoutItemDTO(11L, 1L, "Field", "Child 11", 1, 10, "TEST33")
// )));
//
// for (ApiLayoutItemDTO item : root.getChildren()) {
// item.setChildOccCnt(1);
// }
//
// System.out.println("Before moving:");
// printTree(root);
moveNodeDepth(root, getNodeById(root, 9L), getNodeById(root, 9L).getLoutItemDepth() - 1);
printTree(root);
moveNodeDepth(root, getNodeById(root, 9L), getNodeById(root, 9L).getLoutItemDepth() - 1);
printTree(root);
moveNode(root, getNodeById(root, 9L), true);
moveNodeDepth(root, getNodeById(root, 3L), getNodeById(root, 3L).getLoutItemDepth() + 1);
printTree(root);
ApiLayoutDTO layout = new ApiLayoutDTO();
layout.setComputedLayoutItemRoot(root);
System.out.println(layout.buildMessage());
}
//
// moveNodeDepth(root, getNodeById(root, 4L), getNodeById(root, 4L).getLoutItemDepth() + 1);
// printTree(root);
// moveNodeDepth(root, getNodeById(root, 5L), getNodeById(root, 5L).getLoutItemDepth() + 1);
// printTree(root);
// moveNodeDepth(root, getNodeById(root, 7L), getNodeById(root, 7L).getLoutItemDepth() + 1);
// printTree(root);
// moveNodeDepth(root, getNodeById(root, 8L), getNodeById(root, 8L).getLoutItemDepth() + 1);
// printTree(root);
// moveNodeDepth(root, getNodeById(root, 10L), getNodeById(root, 10L).getLoutItemDepth() + 1);
// printTree(root);
// moveNodeDepth(root, getNodeById(root, 11L), getNodeById(root, 11L).getLoutItemDepth() + 1);
// printTree(root);
// moveNodeDepth(root, getNodeById(root, 9L), getNodeById(root, 9L).getLoutItemDepth() + 1);
// printTree(root);
//// moveNodeDepth(root, getNodeById(root, 6L), getNodeById(root, 6L).getLoutItemDepth() + 1);
//// printTree(root);
// moveNodeDepth(root, getNodeById(root, 9L), getNodeById(root, 9L).getLoutItemDepth() - 1);
// printTree(root);
//
// moveNodeDepth(root, getNodeById(root, 9L), getNodeById(root, 9L).getLoutItemDepth() - 1);
// printTree(root);
//
// moveNode(root, getNodeById(root, 9L), true);
//
// moveNodeDepth(root, getNodeById(root, 3L), getNodeById(root, 3L).getLoutItemDepth() + 1);
// printTree(root);
//
// ApiLayoutDTO layout = new ApiLayoutDTO();
// layout.setComputedLayoutItemRoot(root);
// System.out.println(layout.buildMessage());
// }
}
@@ -1,9 +1,9 @@
package com.eactive.testmaster.client.dto;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
public class ApiRequestDTO implements Serializable {
@@ -2,7 +2,6 @@ package com.eactive.testmaster.client.dto.internal;
import com.eactive.testmaster.client.dto.ApiRequestDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -1,10 +1,15 @@
package com.eactive.testmaster.client.entity;
import com.eactive.testmaster.user.entity.StaffUser;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "API_COLLECTION")
@@ -2,10 +2,13 @@ package com.eactive.testmaster.client.entity;
import com.eactive.testmaster.server.entity.Server;
import com.eactive.testmaster.user.entity.StaffUser;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.time.LocalDateTime;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Type;
public class ApiRequestHistory {
@Id
@@ -2,9 +2,13 @@ package com.eactive.testmaster.client.entity;
import com.eactive.testmaster.server.entity.Server;
import com.eactive.testmaster.user.entity.StaffUser;
import javax.persistence.*;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@@ -1,8 +1,12 @@
package com.eactive.testmaster.client.entity;
import com.eactive.testmaster.user.entity.StaffUser;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "API_SCENARIO")
@@ -4,7 +4,6 @@ import com.eactive.testmaster.client.dto.ApiLayoutItemDTO;
import com.eactive.testmaster.client.entity.ApiLayoutItem;
import com.eactive.testmaster.client.repository.ApiLayoutItemRepository;
import com.eactive.testmaster.common.mapper.CommonMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@@ -3,13 +3,12 @@ package com.eactive.testmaster.client.mapper;
import com.eactive.testmaster.client.dto.ApiScenarioDTO;
import com.eactive.testmaster.client.entity.ApiScenario;
import com.eactive.testmaster.client.repository.ApiScenarioRepository;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
@Component
public abstract class ApiScenarioMapper {
@@ -2,11 +2,10 @@ package com.eactive.testmaster.client.repository;
import com.eactive.testmaster.client.entity.ApiCollection;
import com.eactive.testmaster.user.entity.StaffUser;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
public interface ApiCollectionRepository extends JpaRepository<ApiCollection, String>, JpaSpecificationExecutor<ApiCollection> {
List<ApiCollection> findAllByOwner(StaffUser owner);
@@ -2,11 +2,10 @@ package com.eactive.testmaster.client.repository;
import com.eactive.testmaster.client.entity.ApiScenario;
import com.eactive.testmaster.user.entity.StaffUser;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
public interface ApiScenarioRepository extends JpaRepository<ApiScenario, String>, JpaSpecificationExecutor<ApiScenario> {
List<ApiScenario> findAllByOwner(StaffUser owner);
@@ -6,14 +6,13 @@ import com.eactive.testmaster.client.repository.ApiCollectionRepository;
import com.eactive.testmaster.client.repository.ApiRequestRepository;
import com.eactive.testmaster.common.exception.NotFoundException;
import com.eactive.testmaster.user.entity.StaffUser;
import java.util.List;
import java.util.UUID;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;
import javax.transaction.Transactional;
import java.util.List;
import java.util.UUID;
@Service
@Transactional
public class ApiRequestMgmtService {
@@ -1,17 +1,16 @@
package com.eactive.testmaster.client.service;
import com.eactive.testmaster.client.repository.ApiRequestRepository;
import java.sql.Connection;
import java.sql.Statement;
import javax.sql.DataSource;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import javax.transaction.Transactional;
import java.sql.Connection;
import java.sql.Statement;
@Service
@Transactional
@@ -2,12 +2,11 @@ package com.eactive.testmaster.client.service;
import com.eactive.testmaster.client.entity.ApiScenario;
import com.eactive.testmaster.client.repository.ApiScenarioRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
import java.util.UUID;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Transactional
@@ -7,7 +7,6 @@ import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.util.CharsetUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -15,20 +15,29 @@ import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.*;
import io.netty.handler.codec.http.DefaultFullHttpRequest;
import io.netty.handler.codec.http.DefaultHttpHeaders;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpContentDecompressor;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.util.CharsetUtil;
import java.util.concurrent.CompletableFuture;
import javax.net.ssl.SSLException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.net.ssl.SSLException;
import java.util.concurrent.CompletableFuture;
@Service
public class NettyHttpApiClient implements ApiClient {