InstanceMetadata { public static String resourceShortName(String resource) { return Iterables.getLast(Splitter.on("/").split(resource)); } InstanceMetadata(JsonFactory jsonFactory, HttpTransport httpTransport); String metadata(String keyName); static String resourceShortName(String resource); String customMetadata(String keyName); OAuth2ServiceTokenMetadata serviceToken(final String scope); OAuth2ServiceTokenMetadata serviceToken(final String serviceAccount, final String scope); NetworkMetadata network();  }
@Test public void testResourceShortName() { assertEquals("rtb-us-east2", InstanceMetadata.resourceShortName("projects/123/zones/rtb-us-east2")); assertEquals("foo", InstanceMetadata.resourceShortName("foo")); }