Compare commits

..

1 Commits

Author SHA1 Message Date
huangsimin
7b38c1eaf4 Merge tag 'v0.0.1' into develop
release v0.0.1
2020-01-17 15:17:19 +08:00
4 changed files with 11 additions and 74 deletions

14
pom.xml
View File

@ -23,12 +23,6 @@
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
@ -55,6 +49,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
@ -69,6 +69,4 @@
</plugins>
</build>
</project>

View File

@ -2,12 +2,8 @@ package com.yame.uml;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication
@Configuration
public class Application {
public static void main(String[] args) {

View File

@ -19,13 +19,12 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.error.PSystemError;
@RestController
@RequestMapping("/api")
@Slf4j
public class API {
public class api {
static public String getUmlSource(String source) {
// encapsulate the UML syntax if necessary
@ -46,7 +45,7 @@ public class API {
}
@PostMapping("/v1/megreflow")
public Result megreSVG(@RequestParam("src") String src, @RequestParam("dst") String dst) throws IOException {
public Result megreSVG(@RequestParam("src") String src, @RequestParam("dst") String dst) throws IOException {
String source = getUmlSource(src);
List<BlockUml> srcblocks = new SourceStringReader(source).getBlocks();
@ -55,14 +54,9 @@ public class API {
Result result = new Result();
if (srcblocks.size() != 0 && dstblocks.size() != 0) {
BlockUml sblock = srcblocks.get(0);
BlockUml dblock = srcblocks.get(0);
Diagram d1 = sblock.getDiagram();
Diagram d2 = dblock.getDiagram();
if(srcblocks.size() != 0 && dstblocks.size() != 0) {
UmlSource s1 = d1.getSource();
UmlSource s2 = d2.getSource();
}
result.setType(ResultType.ErrorMegreUML2SVG);
return result;

View File

@ -1,63 +1,12 @@
package com.yame.control;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*;
import java.util.HashMap;
import com.fasterxml.jackson.core.JsonEncoding;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.ReadContext;
import com.yame.uml.Application;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import lombok.extern.slf4j.Slf4j;
/**
* TestAPI
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Slf4j
@SpringBootTest
public class TestAPI {
@LocalServerPort
String port;
@Autowired
TestRestTemplate rest;
String domain;
@Before
public void init() {
domain = "http://localhost:" + port;
}
@Test
public void uml2SVG() {
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("data", "123");
String resp = rest.postForObject(domain + "/api/v1/uml2svg", map, String.class);
ReadContext cxt = JsonPath.parse(resp);
assertEquals(cxt.read("$.type").toString(), "{desc=Error Source2SVG, code=-102, success=false}");
log.info(resp.toString());
}
}