Search in sources :

Example 1 with Extensions

use of com.squareup.wire.schema.Extensions in project schema2proto by entur.

the class SerializationTest method testBuildProtoFile.

@Test
public void testBuildProtoFile() {
    ProtoFile f = new ProtoFile(Syntax.PROTO_3, "default");
    List<EnumConstant> values = new ArrayList<EnumConstant>();
    List<OptionElement> elements = new ArrayList<>();
    List<Reserved> reserveds = new ArrayList<>();
    Options constantOptions = new Options(ProtoType.BOOL, elements);
    Location valueLocation = new Location("base", "file", 1, 2);
    values.add(new EnumConstant(valueLocation, "VAL1", 1, "doc", constantOptions));
    Options options = new Options(ProtoType.BOOL, new ArrayList<>());
    f.types().add(new EnumType(ProtoType.INT32, valueLocation, "doc", "Name", values, reserveds, options));
    Location messagLocation = new Location("base", "path", 1, 1);
    ImmutableList<Field> declaredFields = ImmutableList.copyOf(new ArrayList<>());
    List<Field> extensionFields = new ArrayList<>();
    ImmutableList<OneOf> oneOfs = ImmutableList.copyOf(new ArrayList<>());
    ImmutableList<Type> nestedTypes = ImmutableList.copyOf(new ArrayList<>());
    List<Extensions> extensionsList = new ArrayList<>();
    List<OptionElement> messageOptionElements = new ArrayList<>();
    Options messageOptions = new Options(ProtoType.BOOL, messageOptionElements);
    MessageType message = new MessageType(ProtoType.BOOL, messagLocation, "doc", "messagename", declaredFields, extensionFields, oneOfs, nestedTypes, extensionsList, reserveds, messageOptions);
    f.types().add(message);
    String schema = f.toSchema();
    assertNotNull(schema);
}
Also used : Options(com.squareup.wire.schema.Options) ProtoFile(com.squareup.wire.schema.ProtoFile) ArrayList(java.util.ArrayList) Extensions(com.squareup.wire.schema.Extensions) Field(com.squareup.wire.schema.Field) OneOf(com.squareup.wire.schema.OneOf) ProtoType(com.squareup.wire.schema.ProtoType) Type(com.squareup.wire.schema.Type) EnumType(com.squareup.wire.schema.EnumType) MessageType(com.squareup.wire.schema.MessageType) EnumType(com.squareup.wire.schema.EnumType) OptionElement(com.squareup.wire.schema.internal.parser.OptionElement) EnumConstant(com.squareup.wire.schema.EnumConstant) MessageType(com.squareup.wire.schema.MessageType) Reserved(com.squareup.wire.schema.Reserved) Location(com.squareup.wire.schema.Location) Test(org.junit.jupiter.api.Test)

Aggregations

EnumConstant (com.squareup.wire.schema.EnumConstant)1 EnumType (com.squareup.wire.schema.EnumType)1 Extensions (com.squareup.wire.schema.Extensions)1 Field (com.squareup.wire.schema.Field)1 Location (com.squareup.wire.schema.Location)1 MessageType (com.squareup.wire.schema.MessageType)1 OneOf (com.squareup.wire.schema.OneOf)1 Options (com.squareup.wire.schema.Options)1 ProtoFile (com.squareup.wire.schema.ProtoFile)1 ProtoType (com.squareup.wire.schema.ProtoType)1 Reserved (com.squareup.wire.schema.Reserved)1 Type (com.squareup.wire.schema.Type)1 OptionElement (com.squareup.wire.schema.internal.parser.OptionElement)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1