### Question:
ContactsBackend extends ObmSyncBackend<WindowingContact> { @Override public ServerId createOrUpdate(UserDataRequest udr, CollectionId collectionId, ServerId serverId, String clientId, IApplicationData data) throws CollectionNotFoundException, ProcessingEmailException, DaoException, UnexpectedObmSyncServerException, ItemNotFoundException, NoPermissionException { MSContact contact = (MSContact) data; Folder folder = folderSnapshotDao.get(udr.getUser(), udr.getDevice(), collectionId); if (isUpdate(serverId)) { return storeContact(udr, folder, serverId, clientId, contact); } return createContact(udr, folder, serverId, clientId, contact); } @Inject @VisibleForTesting  ContactsBackend(MappingService mappingService, 
			BookClient.Factory bookClientFactory, 
			ContactConfiguration contactConfiguration,
			WindowingDao windowingDao,
			ClientIdService clientIdService,
			ContactConverter contactConverter,
			DateService dateService,
			OpushResourcesHolder opushResourcesHolder,
			ContactCreationIdempotenceService creationIdempotenceService,
			FolderSnapshotDao folderSnapshotDao); @Override PIMDataType getPIMDataType(); @Override BackendFolders getBackendFolders(UserDataRequest udr); @Override int getItemEstimateSize(UserDataRequest udr, ItemSyncState state, CollectionId collectionId, 
		SyncCollectionOptions syncCollectionOptions); @Override ServerId createOrUpdate(UserDataRequest udr, CollectionId collectionId,
			ServerId serverId, String clientId, IApplicationData data); @Override void delete(UserDataRequest udr, CollectionId collectionId, ServerId serverId, Boolean moveToTrash); @Override List<ItemChange> fetch(UserDataRequest udr, CollectionId collectionId, List<ServerId> fetchServerIds, SyncCollectionOptions syncCollectionOptions,
				ItemSyncState previousItemSyncState, SyncKey newSyncKey); @Override List<ItemChange> fetch(UserDataRequest udr, CollectionId collectionId, List<ServerId> fetchServerIds, SyncCollectionOptions syncCollectionOptions); @Override ServerId move(UserDataRequest udr, Folder srcFolder, Folder dstFolder,
			ServerId messageId); @Override void emptyFolderContent(UserDataRequest udr, Folder folder,
			boolean deleteSubFolder); @Override void initialize(DeviceId deviceId, CollectionId collectionId, FilterType filterType, SyncKey newSyncKey); @Override BackendId createFolder(UserDataRequest udr, FolderCreateRequest folderCreateRequest,
			Optional<BackendId> backendId);  }### Answer:
@Test public void testCreateOrUpdate() throws Exception { CollectionId collectionId = CollectionId.of(1); int bookId = 5; ServerId serverId = collectionId.serverId(215); String clientId = "1"; String clientIdHash = "146565647814688"; expect(folderSnapshotDao.get(user, device, collectionId)).andReturn( org.obm.push.bean.change.hierarchy.Folder.builder() .displayName("folder") .collectionId(collectionId) .backendId(AddressBookId.of(bookId)) .folderType(FolderType.DEFAULT_CONTACTS_FOLDER) .build()); expect(clientIdService.hash(userDataRequest, clientId)).andReturn(clientIdHash); Contact contact = newContactObject(serverId.getItemId()); expect(bookClient.storeContact(token, bookId, contact, clientIdHash)) .andReturn(contact).once(); expect(mappingService.getServerIdFor(collectionId, String.valueOf(serverId.getItemId()))) .andReturn(serverId); MSContact msContact = new MSContact(); mocks.replay(); ServerId newServerId = contactsBackend.createOrUpdate(userDataRequest, collectionId, serverId, clientId, msContact); mocks.verify(); assertThat(newServerId).isEqualTo(collectionId.serverId(215)); }