### Question:
ResourceSetLabelRegistration { void updateLabelsForNewResourceSet(ResourceSetDescription resourceSet) { JsonValue labels = resourceSet.getDescription().get(OAuth2Constants.ResourceSets.LABELS); if (!labels.isNull() && labels.size() > 0) { updateLabels(resourceSet, labels.asSet(String.class), Collections.<String>emptySet()); } } @Inject  ResourceSetLabelRegistration(UmaLabelsStore labelsStore);   }### Answer:
@Test public void shouldUpdateLabelsForNewResourceSet() throws Exception { ResourceSetDescription resourceSet = newResourceSet("LABEL_ONE"); givenLabelsDoesNotExist("LABEL_ONE"); labelRegistration.updateLabelsForNewResourceSet(resourceSet); ArgumentCaptor<ResourceSetLabel> labelCaptor = ArgumentCaptor.forClass(ResourceSetLabel.class); verify(labelsStore).create(eq("REALM"), eq("RESOURCE_OWNER_ID"), labelCaptor.capture()); assertThat(labelCaptor.getValue().getId()).isEqualTo("CLIENT_ID/LABEL_ONE"); assertThat(labelCaptor.getValue().getName()).isEqualTo("LABEL_ONE"); assertThat(labelCaptor.getValue().getType()).isEqualTo(LabelType.SYSTEM); assertThat(labelCaptor.getValue().getResourceSetIds()).containsOnly("RESOURCE_SET_ID"); }
@Test public void shouldNotUpdateLabelsForNewResourceSetWithNoLabels() throws Exception { ResourceSetDescription resourceSet = newResourceSet(); labelRegistration.updateLabelsForNewResourceSet(resourceSet); verify(labelsStore, never()).create(eq("REALM"), eq("RESOURCE_OWNER_ID"), any(ResourceSetLabel.class)); }
@Test public void shouldUpdateLabelUsingClientIdIfClientDisplayNameIsNull() throws Exception { ResourceSetDescription resourceSet = newResourceSet("LABEL_ONE"); givenLabelsDoesNotExist("LABEL_ONE"); labelRegistration.updateLabelsForNewResourceSet(resourceSet); ArgumentCaptor<ResourceSetLabel> labelCaptor = ArgumentCaptor.forClass(ResourceSetLabel.class); verify(labelsStore).create(eq("REALM"), eq("RESOURCE_OWNER_ID"), labelCaptor.capture()); assertThat(labelCaptor.getValue().getId()).isEqualTo("CLIENT_ID/LABEL_ONE"); assertThat(labelCaptor.getValue().getName()).isEqualTo("LABEL_ONE"); }