Search in sources :

Example 1 with ProtoParser

use of org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser in project incubator-servicecomb-java-chassis by apache.

the class TestProtoToStringGenerator method protoToString.

@Test
public void protoToString() {
    ProtoParser protoParser = new ProtoParser();
    Proto proto = protoParser.parseFromContent(content);
    String newContent = new ProtoToStringGenerator(proto).protoToString();
    Assert.assertEquals(content, newContent);
}
Also used : ProtoParser(org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser) Proto(io.protostuff.compiler.model.Proto) Test(org.junit.Test)

Example 2 with ProtoParser

use of org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser in project java-chassis by ServiceComb.

the class SwaggerToProtoGenerator method createProto.

protected Proto createProto() {
    StringBuilder sb = new StringBuilder();
    appendLine(sb, "syntax = \"proto3\";");
    for (String importMsg : imports) {
        appendLine(sb, "import \"%s\";", importMsg);
    }
    if (StringUtils.isNotEmpty(protoPackage)) {
        sb.append("package ").append(protoPackage).append(";\n");
    }
    sb.append(msgStringBuilder);
    sb.append(serviceBuilder);
    ProtoParser protoParser = new ProtoParser();
    return protoParser.parseFromContent(sb.toString());
}
Also used : ProtoParser(org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser)

Example 3 with ProtoParser

use of org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser in project java-chassis by ServiceComb.

the class TestProtoToStringGenerator method protoToString.

@Test
public void protoToString() {
    ProtoParser protoParser = new ProtoParser();
    Proto proto = protoParser.parseFromContent(content);
    String newContent = new ProtoToStringGenerator(proto).protoToString();
    Assert.assertEquals(content, newContent);
}
Also used : ProtoParser(org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser) Proto(io.protostuff.compiler.model.Proto) Test(org.junit.Test)

Example 4 with ProtoParser

use of org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser in project incubator-servicecomb-java-chassis by apache.

the class SwaggerToProtoGenerator method createProto.

protected Proto createProto() {
    StringBuilder sb = new StringBuilder();
    appendLine(sb, "syntax = \"proto3\";");
    for (String importMsg : imports) {
        appendLine(sb, "import \"%s\";", importMsg);
    }
    if (StringUtils.isNotEmpty(protoPackage)) {
        sb.append("package ").append(protoPackage).append(";\n");
    }
    sb.append(msgStringBuilder);
    sb.append(serviceBuilder);
    ProtoParser protoParser = new ProtoParser();
    return protoParser.parseFromContent(sb.toString());
}
Also used : ProtoParser(org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser)

Aggregations

ProtoParser (org.apache.servicecomb.foundation.protobuf.internal.parser.ProtoParser)4 Proto (io.protostuff.compiler.model.Proto)2 Test (org.junit.Test)2