feat:acs交互接口定义
This commit is contained in:
@@ -199,6 +199,12 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.code.nl.server.acs;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.AcsCommonResult;
|
||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||
import cn.code.nl.framework.common.util.spring.SpringUtils;
|
||||
import cn.code.nl.framework.execute.util.http.AcsUtil;
|
||||
import cn.code.nl.module.infra.api.config.ConfigApi;
|
||||
import cn.code.nl.module.task.job.dto.AcsTaskDTO;
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.code.nl.module.task.enums.AcsApiConstants.ACS_TASK_API;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@SpringJUnitConfig
|
||||
@ContextConfiguration(classes = AcsUtilLocalSpringTest.TestConfiguration.class)
|
||||
class AcsUtilLocalSpringTest {
|
||||
|
||||
private static final String SERVER_ADDRESS = "http://127.0.0.1:8011";
|
||||
|
||||
@Test
|
||||
void shouldPostIssueTaskToLocalAcs() {
|
||||
AcsCommonResult<AcsIssueTaskResp> result = AcsUtil.post(SERVER_ADDRESS, ACS_TASK_API,
|
||||
List.of(buildAcsTask()), AcsIssueTaskResp.class);
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
private AcsTaskDTO buildAcsTask() {
|
||||
AcsTaskDTO task = new AcsTaskDTO();
|
||||
task.setTaskId(10001L);
|
||||
task.setTaskCode("LOCAL-ACS-TEST-10001");
|
||||
task.setStartDeviceCode("START-TEST-01");
|
||||
task.setNextDeviceCode("END-TEST-01");
|
||||
task.setPriority("1");
|
||||
task.setVehicleCode("BOX-TEST-01");
|
||||
task.setTaskType("TRANSFER");
|
||||
task.setAgvSystemType("ACS");
|
||||
task.setProductArea("TEST");
|
||||
task.setRemark("local acs issue task test");
|
||||
task.setPayload(Map.of("source", "AcsUtilLocalSpringTest"));
|
||||
return task;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class AcsIssueTaskResp {
|
||||
private List<FailedTask> failedTasks;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class FailedTask {
|
||||
private Long taskId;
|
||||
private String errorMessage;
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
SpringUtils springUtils() {
|
||||
return new SpringUtils();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ConfigApi configApi() {
|
||||
return key -> CommonResult.success("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user