@Test
public void buildComplexType() throws Exception {

  EdmComplexType baseType = mock(EdmComplexType.class);
  when(baseType.getFullQualifiedName()).thenReturn(new FullQualifiedName("namespace", "BaseTypeName"));
  ContextURL contextURL = ContextURL.with().serviceRoot(serviceRoot)
      .type(baseType)
      .build();
  assertEquals(serviceRoot + "$metadata#namespace.BaseTypeName",
      ContextURLBuilder.create(contextURL).toASCIIString());
  contextURL = ContextURL.with().serviceRoot(serviceRoot)
      .type(baseType)
      .asCollection()
      .build();
  assertEquals(serviceRoot + "$metadata#Collection(namespace.BaseTypeName)",
      ContextURLBuilder.create(contextURL).toASCIIString());
}