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

View File

@ -2,12 +2,8 @@ package com.yame.uml;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication @SpringBootApplication
@Configuration
public class Application { public class Application {
public static void main(String[] args) { 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.FileFormatOption;
import net.sourceforge.plantuml.SourceStringReader; import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.error.PSystemError; import net.sourceforge.plantuml.error.PSystemError;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
@Slf4j @Slf4j
public class API { public class api {
static public String getUmlSource(String source) { static public String getUmlSource(String source) {
// encapsulate the UML syntax if necessary // encapsulate the UML syntax if necessary
@ -55,14 +54,9 @@ public class API {
Result result = new Result(); Result result = new Result();
if (srcblocks.size() != 0 && dstblocks.size() != 0) { 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();
UmlSource s1 = d1.getSource();
UmlSource s2 = d2.getSource();
} }
result.setType(ResultType.ErrorMegreUML2SVG); result.setType(ResultType.ErrorMegreUML2SVG);
return result; return result;

View File

@ -1,63 +1,12 @@
package com.yame.control; 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.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 * TestAPI
*/ */
@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Slf4j
public class TestAPI { 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());
}
} }