@Test public void testExtractResourceGroup() { assertEquals(extractResourceGroup(null), null); assertEquals(extractResourceGroup(""), null); assertEquals( extractResourceGroup("/subscriptions/subscription/resourceGroups/jclouds-northeurope/providers/Microsoft.Compute/virtualMachines/resources-8c5"), "jclouds-northeurope"); assertEquals(extractResourceGroup("/subscriptions/subscription/resourceGroups/jclouds-west"), "jclouds-west"); assertEquals(extractResourceGroup("/resourceGroups/jclouds-west2"), "jclouds-west2"); assertEquals( extractResourceGroup("/resourceGroups/jclouds-northeurope2/providers/Microsoft.Compute/virtualMachines/resources-8c5"), "jclouds-northeurope2"); assertEquals(extractResourceGroup("resourceGroups/jclouds-west2"), null); assertEquals( extractResourceGroup("resourceGroups/jclouds-northeurope2/providers/Microsoft.Compute/virtualMachines/resources-8c5"), null); assertEquals( extractResourceGroup("/subscriptions/subscription/providers/Microsoft.Compute/virtualMachines/resources-8c5"), null); assertEquals( extractResourceGroup("/subscriptions/subscription/resourceGroups null); }
public static String extractResourceGroup(String uri) { if (uri == null) return null; Matcher m = RESOURCE_GROUP_PATTERN.matcher(uri); return m.matches() ? m.group(1) : null; }
IdReference { public static String extractResourceGroup(String uri) { if (uri == null) return null; Matcher m = RESOURCE_GROUP_PATTERN.matcher(uri); return m.matches() ? m.group(1) : null; } }
IdReference { public static String extractResourceGroup(String uri) { if (uri == null) return null; Matcher m = RESOURCE_GROUP_PATTERN.matcher(uri); return m.matches() ? m.group(1) : null; }  }
IdReference { public static String extractResourceGroup(String uri) { if (uri == null) return null; Matcher m = RESOURCE_GROUP_PATTERN.matcher(uri); return m.matches() ? m.group(1) : null; }  @Nullable abstract String id(); @Nullable String resourceGroup(); @Nullable String name(); @SerializedNames({"id"}) static IdReference create(final String id); static String extractName(String uri); static String extractResourceGroup(String uri); }
IdReference { public static String extractResourceGroup(String uri) { if (uri == null) return null; Matcher m = RESOURCE_GROUP_PATTERN.matcher(uri); return m.matches() ? m.group(1) : null; }  @Nullable abstract String id(); @Nullable String resourceGroup(); @Nullable String name(); @SerializedNames({"id"}) static IdReference create(final String id); static String extractName(String uri); static String extractResourceGroup(String uri);  }