AttributeRegistrar { void setId(String identifier, boolean clearPendingOnIdChange) { synchronized (idLock) { if (clearPendingOnIdChange && !UAStringUtil.equals(this.identifier, identifier)) { mutationStore.removeAll(); } this.identifier = identifier; } } AttributeRegistrar(AttributeApiClient apiClient, PendingAttributeMutationStore mutationStore);   }
@Test public void testSetId() { registrar.setId(null, false); AttributeMutation mutation = AttributeMutation.newSetAttributeMutation("expected_key", JsonValue.wrapOpt("expected_value"), 100); List<AttributeMutation> pendingAttributeMutations = Collections.singletonList(mutation); registrar.addPendingMutations(pendingAttributeMutations); registrar.setId("what", false); assertEquals(store.peek(), pendingAttributeMutations); registrar.setId("what", true); assertEquals(store.peek(), pendingAttributeMutations); registrar.setId("something-else", true); assertNull(store.peek()); }