@Test public void update_ExistingDocument_ShouldDoPartialUpdate() { Todo todoEntry = TodoTestUtil.createModel(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE); repository.update(todoEntry); ArgumentCaptor<PartialUpdate> partialUpdateArgument = ArgumentCaptor.forClass(PartialUpdate.class); verify(solrTemplateMock, times(1)).saveBean(partialUpdateArgument.capture()); verify(solrTemplateMock, times(1)).commit(); PartialUpdate update = partialUpdateArgument.getValue(); assertEquals(todoEntry.getId().toString(), update.getIdField().getValue()); List<UpdateField> updatedFields = update.getUpdates(); assertEquals(2, updatedFields.size()); for (UpdateField updatedField: updatedFields) { String fieldName = updatedField.getName(); if (fieldName.equals(TodoDocument.FIELD_DESCRIPTION)) { assertEquals(todoEntry.getDescription(), updatedField.getValue()); } else if (fieldName.equals(TodoDocument.FIELD_TITLE)) { assertEquals(todoEntry.getTitle(), updatedField.getValue()); } else { fail("Unknown field: " + fieldName); } } }
@Override public void update(Todo todoEntry) { LOGGER.debug("Performing partial update for todo entry: {}", todoEntry); PartialUpdate update = new PartialUpdate(TodoDocument.FIELD_ID, todoEntry.getId().toString()); update.add(TodoDocument.FIELD_DESCRIPTION, todoEntry.getDescription()); update.add(TodoDocument.FIELD_TITLE, todoEntry.getTitle()); solrTemplate.saveBean(update); solrTemplate.commit(); }
TodoDocumentRepositoryImpl implements PartialUpdateRepository { @Override public void update(Todo todoEntry) { LOGGER.debug("Performing partial update for todo entry: {}", todoEntry); PartialUpdate update = new PartialUpdate(TodoDocument.FIELD_ID, todoEntry.getId().toString()); update.add(TodoDocument.FIELD_DESCRIPTION, todoEntry.getDescription()); update.add(TodoDocument.FIELD_TITLE, todoEntry.getTitle()); solrTemplate.saveBean(update); solrTemplate.commit(); } }
TodoDocumentRepositoryImpl implements PartialUpdateRepository { @Override public void update(Todo todoEntry) { LOGGER.debug("Performing partial update for todo entry: {}", todoEntry); PartialUpdate update = new PartialUpdate(TodoDocument.FIELD_ID, todoEntry.getId().toString()); update.add(TodoDocument.FIELD_DESCRIPTION, todoEntry.getDescription()); update.add(TodoDocument.FIELD_TITLE, todoEntry.getTitle()); solrTemplate.saveBean(update); solrTemplate.commit(); }  }
TodoDocumentRepositoryImpl implements PartialUpdateRepository { @Override public void update(Todo todoEntry) { LOGGER.debug("Performing partial update for todo entry: {}", todoEntry); PartialUpdate update = new PartialUpdate(TodoDocument.FIELD_ID, todoEntry.getId().toString()); update.add(TodoDocument.FIELD_DESCRIPTION, todoEntry.getDescription()); update.add(TodoDocument.FIELD_TITLE, todoEntry.getTitle()); solrTemplate.saveBean(update); solrTemplate.commit(); }  @Override void update(Todo todoEntry); }
TodoDocumentRepositoryImpl implements PartialUpdateRepository { @Override public void update(Todo todoEntry) { LOGGER.debug("Performing partial update for todo entry: {}", todoEntry); PartialUpdate update = new PartialUpdate(TodoDocument.FIELD_ID, todoEntry.getId().toString()); update.add(TodoDocument.FIELD_DESCRIPTION, todoEntry.getDescription()); update.add(TodoDocument.FIELD_TITLE, todoEntry.getTitle()); solrTemplate.saveBean(update); solrTemplate.commit(); }  @Override void update(Todo todoEntry);  }