### Question:
SyncUtils { public static String selectAppropriateClientName(Map<String, String> availableResourceLinks, String category, SyncOperation operation) { ClassConfiguration classConfiguration = getSyncConfigurationService().getClassConfiguration(category, operation); String preferredClient = getClassPreferredClient(classConfiguration); if (StringUtils.isBlank(preferredClient)) { preferredClient = getGlobalPreferredClient(); } if (availableResourceLinks.containsKey(preferredClient)) { return preferredClient; } else { return getFirstKey(availableResourceLinks); } }  static Map<String, String> getLinks(String json); static String getParentBaseUrl(String clientName); static String getSpecificClientAddress(String clientName); static boolean clientHasSpecificAddress(String clientName, OpenMRSSyncInstance instance); static String getLocalBaseUrl(); static String getLocalInstanceId(); static String getPullUrl(Map<String, String> resourceLinks, String clientName, OpenMRSSyncInstance instance); static String getPushUrl(Map<String, String> resourceLinks, String clientName, OpenMRSSyncInstance instance); static String getClientSpecificLogin(String clientName); static String getClientSpecificPassword(String clientName); static boolean clientHasSpecificCridentials(String clientName, OpenMRSSyncInstance instance); static String getClientLogin(String clientName, OpenMRSSyncInstance instance); static String getClientPassword(String clientName, OpenMRSSyncInstance instance); static String getValueOfAtomfeedEventTag(List tags, AtomfeedTagContent atomfeedTagContent); static String getFullUrl(String baseAddress, String path); static String selectAppropriateClientName(Map<String, String> availableResourceLinks, String category,
			SyncOperation operation); static String getClassPreferredClient(ClassConfiguration classConfiguration); static String getGlobalPreferredClient(); static String extractUUIDFromResourceLinks(Map<String, String> resourceLinks, String category,
			String preferredClient); static boolean compareLocalAndPulled(String clientName, String category, Object from, Object dest); static String prettySerialize(Map<T, T> map); static String serialize(T object); static T deserialize(String object, Class<T> clazz); static Map<String, String> deserializeJsonToStringsMap(String json); static boolean checkIfParamIsFeedFilter(Object tag); static boolean checkIfParamIsEventAction(String actionName); static SyncConfigurationService getSyncConfigurationService(); static Gson createDefaultGson(); static MergeBehaviour getMergeBehaviour(); static String getEventHandlerName(); static boolean parentInstanceUriIsEmpty(); static boolean isDeleteAction(String action); static boolean isUpdateAction(String action); static boolean isCreateAction(String action); static boolean isUnauthorizedException(Throwable e); static boolean isAuditMessageCategory(SyncCategory category);  }### Answer:
@Test public void selectAppropriateClientName_shouldReturnClassClientIfExist() throws Exception { String expected = LOCATION_PREFERRED_CLIENT; String actual = SyncUtils.selectAppropriateClientName(prepareDummyLinksTemplate(), "location", SyncOperation.PULL); Assert.assertNotNull(actual); Assert.assertEquals(expected, actual); }
@Test public void selectAppropriateClientName_shouldReturnFirstFromLinkTemplateIfGlobalAndClassNotExist() throws Exception { Mockito.when(administrationService.getGlobalProperty(SyncConstants.RESOURCE_PREFERRED_CLIENT, SyncConstants.DEFAULT_SYNC_2_CLIENT)).thenReturn(null); String expected = SyncConstants.FHIR_CLIENT; String actual = SyncUtils.selectAppropriateClientName(prepareDummyLinksTemplate(), "observation", SyncOperation.PULL); Assert.assertNotNull(actual); Assert.assertEquals(expected, actual); }
@Test public void selectAppropriateClientName_shouldReturnGlobalClientIfClassClientNotExist() throws Exception { String expected = GLOBAL_CLIENT; String actual = SyncUtils.selectAppropriateClientName(prepareDummyLinksTemplate(), "observation", SyncOperation.PUSH); Assert.assertNotNull(actual); Assert.assertEquals(expected, actual); }