### Question:
ResourceGroupIdTemplate { public ResourceGroupId expandTemplate(VariableMap context) { ResourceGroupId id = null; for (ResourceGroupNameTemplate segment : segments) { String expanded = segment.expandTemplate(context); if (id == null) { id = new ResourceGroupId(expanded); } else { id = new ResourceGroupId(id, expanded); } } return id; } @JsonCreator  ResourceGroupIdTemplate(String fullId); static ResourceGroupIdTemplate forSubGroupNamed(ResourceGroupIdTemplate parent, String name); static ResourceGroupIdTemplate fromSegments(List<ResourceGroupNameTemplate> segments); ResourceGroupId expandTemplate(VariableMap context); List<ResourceGroupNameTemplate> getSegments(); Set<String> getVariableNames(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testExpansion() { ResourceGroupIdTemplate template = new ResourceGroupIdTemplate("test.${USER}.${SOURCE}"); ResourceGroupId expected = new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("test"), "u"), "s"); assertEquals(template.expandTemplate(new VariableMap(ImmutableMap.of("USER", "u", "SOURCE", "s"))), expected); template = new ResourceGroupIdTemplate("test.${USER}"); assertEquals(template.expandTemplate(new VariableMap(ImmutableMap.of("USER", "alice.smith", "SOURCE", "s"))), new ResourceGroupId(new ResourceGroupId("test"), "alice.smith")); }