Search in sources :

Example 1 with EnumValue

use of com.google.api.tools.framework.model.EnumValue in project toolkit by googleapis.

the class NodeJSModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    String packageName = "library.v1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    NodeJSModelTypeNameConverter converter = new NodeJSModelTypeNameConverter(packageName);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new JSTypeTable(packageName))).isEqualTo("'GOOD'");
}
Also used : JSTypeTable(com.google.api.codegen.util.js.JSTypeTable) TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) Test(org.junit.Test)

Example 2 with EnumValue

use of com.google.api.tools.framework.model.EnumValue in project toolkit by googleapis.

the class PhpModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    String packageName = "Google\\Example\\Library\\V1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    PhpModelTypeNameConverter converter = new PhpModelTypeNameConverter(packageName);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new PhpTypeTable(packageName))).isEqualTo("Book_Rating::GOOD");
}
Also used : TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) PhpTypeTable(com.google.api.codegen.util.php.PhpTypeTable) Test(org.junit.Test)

Example 3 with EnumValue

use of com.google.api.tools.framework.model.EnumValue in project toolkit by googleapis.

the class GrpcElementDocTransformer method generateEnumValueDocs.

private List<GrpcEnumValueDocView> generateEnumValueDocs(SurfaceNamer namer, EnumType enumElement) {
    ImmutableList.Builder<GrpcEnumValueDocView> valueDocs = ImmutableList.builder();
    for (EnumValue value : enumElement.getValues()) {
        GrpcEnumValueDocView.Builder doc = GrpcEnumValueDocView.newBuilder();
        doc.name(value.getSimpleName());
        doc.number(value.getNumber());
        doc.lines(namer.getDocLines(GapicParser.getDocString(value)));
        valueDocs.add(doc.build());
    }
    return valueDocs.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) EnumValue(com.google.api.tools.framework.model.EnumValue) GrpcEnumValueDocView(com.google.api.codegen.viewmodel.GrpcEnumValueDocView)

Example 4 with EnumValue

use of com.google.api.tools.framework.model.EnumValue in project toolkit by googleapis.

the class CSharpModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    String packageName = "Google.Example.Library.V1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    CSharpModelTypeNameConverter converter = new CSharpModelTypeNameConverter(packageName);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new CSharpTypeTable(packageName))).isEqualTo("Book.Types.Rating.Good");
}
Also used : TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) CSharpTypeTable(com.google.api.codegen.util.csharp.CSharpTypeTable) Test(org.junit.Test)

Example 5 with EnumValue

use of com.google.api.tools.framework.model.EnumValue in project toolkit by googleapis.

the class GoModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new GoTypeTable())).isEqualTo("librarypb.Book_GOOD");
    type = ModelTypeNameConverterTestUtil.getTestType(tempDir, "TopLevelEnum");
    value = type.getEnumType().getValues().get(0);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new GoTypeTable())).isEqualTo("librarypb.TopLevelEnum_FOO");
}
Also used : GoTypeTable(com.google.api.codegen.util.go.GoTypeTable) TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) Test(org.junit.Test)

Aggregations

EnumValue (com.google.api.tools.framework.model.EnumValue)6 TypeRef (com.google.api.tools.framework.model.TypeRef)5 Test (org.junit.Test)5 CSharpTypeTable (com.google.api.codegen.util.csharp.CSharpTypeTable)1 GoTypeTable (com.google.api.codegen.util.go.GoTypeTable)1 JSTypeTable (com.google.api.codegen.util.js.JSTypeTable)1 PhpTypeTable (com.google.api.codegen.util.php.PhpTypeTable)1 RubyTypeTable (com.google.api.codegen.util.ruby.RubyTypeTable)1 GrpcEnumValueDocView (com.google.api.codegen.viewmodel.GrpcEnumValueDocView)1 ImmutableList (com.google.common.collect.ImmutableList)1