Search in sources :

Example 6 with PhpTypeTable

use of com.google.api.codegen.util.php.PhpTypeTable in project toolkit by googleapis.

the class PhpModelTypeNameConverterTest method testNestedMessageFullNameWithPhpNamespace.

@Test
public void testNestedMessageFullNameWithPhpNamespace() {
    String packageName = "Google\\Example\\Library\\V1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestType("myproto", tempDir, "TopLevelMessage", "AnotherSubMessage");
    PhpModelTypeNameConverter converter = new PhpModelTypeNameConverter(packageName);
    PhpTypeTable typeTable = new PhpTypeTable(packageName);
    TypeName typeName = converter.getTypeName(type);
    assertThat(typeName.getFullName()).isEqualTo("\\Google\\Example\\MyProto\\V1\\TopLevelMessage\\AnotherSubMessage");
    typeTable.getAndSaveNicknameFor(typeName);
    assertThat(typeTable.getImports()).containsKey("\\Google\\Example\\MyProto\\V1\\TopLevelMessage\\AnotherSubMessage");
}
Also used : TypeName(com.google.api.codegen.util.TypeName) TypeRef(com.google.api.tools.framework.model.TypeRef) PhpTypeTable(com.google.api.codegen.util.php.PhpTypeTable) Test(org.junit.Test)

Aggregations

PhpTypeTable (com.google.api.codegen.util.php.PhpTypeTable)6 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)3 TypeRef (com.google.api.tools.framework.model.TypeRef)3 Test (org.junit.Test)3 InterfaceModel (com.google.api.codegen.config.InterfaceModel)2 TypeName (com.google.api.codegen.util.TypeName)2 ViewModel (com.google.api.codegen.viewmodel.ViewModel)2 ArrayList (java.util.ArrayList)2 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)1 GapicInterfaceContext (com.google.api.codegen.transformer.GapicInterfaceContext)1 EnumValue (com.google.api.tools.framework.model.EnumValue)1