static ConjureType fromString(String value) throws ParseException { return TypeParser.INSTANCE.parse(value); } }
public ConjureType parse(String input) throws ParseException { ParserState inputParserState = new StringParserState(input); ConjureType resultType = Parsers.eof(typeParser()).parse(inputParserState); if (resultType == null) { throw new ParseException(input, inputParserState); } return parse(new StringParserState(input)); }
@Override public ConjureType parse(ParserState input) throws ParseException { return typeParser().parse(input); }
@Test public void testParser_safelongType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("safelong")) .isEqualTo(PrimitiveType.SAFELONG); }
@Test public void testParser_uuidType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("uuid")) .isEqualTo(PrimitiveType.UUID); }
@Test public void testParser_stringType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("string")) .isEqualTo(PrimitiveType.STRING); }
@Test public void testParser_integerType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("integer")) .isEqualTo(PrimitiveType.INTEGER); }
@Test public void testParser_bearertokenType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("bearertoken")) .isEqualTo(PrimitiveType.BEARERTOKEN); }
@Test public void testParser_doubleType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("double")) .isEqualTo(PrimitiveType.DOUBLE); }
@Test public void testParser_booleanType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("boolean")) .isEqualTo(PrimitiveType.BOOLEAN); }
@Test public void testParser_ridType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("rid")) .isEqualTo(PrimitiveType.RID); }
@Test(expected = ParseException.class) public void testParser_invalidType() throws ParseException { TypeParser.INSTANCE.parse("[]"); }
@Test(expected = ParseException.class) public void testParser_invalidSuffixType() throws ParseException { TypeParser.INSTANCE.parse("string[]"); }
@Test public void testParser_setType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("set<string>")) .isEqualTo(SetType.of(PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("set < string >")) .isEqualTo(SetType.of(PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("set<list<string>>")) .isEqualTo(SetType.of(ListType.of(PrimitiveType.STRING))); }
@Test public void testParser_optionalType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("optional<string>")) .isEqualTo(OptionalType.of(PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("optional < string >")) .isEqualTo(OptionalType.of(PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("optional<list<string>>")) .isEqualTo(OptionalType.of(ListType.of(PrimitiveType.STRING))); }
@Test public void testParser_listType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("list<string>")) .isEqualTo(ListType.of(PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("list < string >")) .isEqualTo(ListType.of(PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("list<list<string>>")) .isEqualTo(ListType.of(ListType.of(PrimitiveType.STRING))); }
@Test public void testParser_binaryType() throws Exception { assertThat(TypeParser.INSTANCE.parse("binary")) .isEqualTo(BinaryType.of()); }
@Test public void testParser_anyType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("any")) .isEqualTo(AnyType.of()); }
@Test public void testParser_mapType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("map<string, string>")) .isEqualTo(MapType.of( PrimitiveType.STRING, PrimitiveType.STRING)); assertThat(TypeParser.INSTANCE.parse("map<map<string, string>, optional<string>>")) .isEqualTo( MapType.of( MapType.of( PrimitiveType.STRING, PrimitiveType.STRING), OptionalType.of(PrimitiveType.STRING))); }
@Test public void testParser_refType() throws ParseException { assertThat(TypeParser.INSTANCE.parse("Foo")) .isEqualTo(LocalReferenceType.of(TypeName.of("Foo"))); }