@Test public void test_draft_repository_should_save_draft() { final NewDraft newDraft = getDraftCreateRequest(); doAnswer(invocationOnMock -> { final Draft entityDraft = (Draft) invocationOnMock.getArguments()[0]; entityDraft.setId(4L); return entityDraft; }).when(draftJpaRepository).save(any(Draft.class)); final long id = draftRepository.saveDraft(newDraft); verify(draftJpaRepository).save(getSaveDraftEntity()); assertEquals(4L, id); }
public long saveDraft(NewDraft newDraft) { final HashMap<String, Object> draft = newDraft.getDraft(); String createDraft = convertToString(draft); org.egov.pgrrest.read.persistence.entity.Draft draftEntity = org.egov.pgrrest.read.persistence.entity.Draft .builder() .serviceCode(newDraft.getServiceCode()) .tenantId(newDraft.getTenantId()) .userId(newDraft.getUserId()) .draft(createDraft) .build(); draftJpaRepository.save(draftEntity); return draftEntity.getId(); }
DraftRepository { public long saveDraft(NewDraft newDraft) { final HashMap<String, Object> draft = newDraft.getDraft(); String createDraft = convertToString(draft); org.egov.pgrrest.read.persistence.entity.Draft draftEntity = org.egov.pgrrest.read.persistence.entity.Draft .builder() .serviceCode(newDraft.getServiceCode()) .tenantId(newDraft.getTenantId()) .userId(newDraft.getUserId()) .draft(createDraft) .build(); draftJpaRepository.save(draftEntity); return draftEntity.getId(); } }
DraftRepository { public long saveDraft(NewDraft newDraft) { final HashMap<String, Object> draft = newDraft.getDraft(); String createDraft = convertToString(draft); org.egov.pgrrest.read.persistence.entity.Draft draftEntity = org.egov.pgrrest.read.persistence.entity.Draft .builder() .serviceCode(newDraft.getServiceCode()) .tenantId(newDraft.getTenantId()) .userId(newDraft.getUserId()) .draft(createDraft) .build(); draftJpaRepository.save(draftEntity); return draftEntity.getId(); } DraftRepository(DraftJpaRepository draftJpaRepository, ObjectMapper objectMapper); }
DraftRepository { public long saveDraft(NewDraft newDraft) { final HashMap<String, Object> draft = newDraft.getDraft(); String createDraft = convertToString(draft); org.egov.pgrrest.read.persistence.entity.Draft draftEntity = org.egov.pgrrest.read.persistence.entity.Draft .builder() .serviceCode(newDraft.getServiceCode()) .tenantId(newDraft.getTenantId()) .userId(newDraft.getUserId()) .draft(createDraft) .build(); draftJpaRepository.save(draftEntity); return draftEntity.getId(); } DraftRepository(DraftJpaRepository draftJpaRepository, ObjectMapper objectMapper); long saveDraft(NewDraft newDraft); DraftResult getDrafts(DraftSearchCriteria searchCriteria); void delete(List<Long> draftIdList); void delete(long draftId); void updateDraft(UpdateDraft draftUpdateRequest); }
DraftRepository { public long saveDraft(NewDraft newDraft) { final HashMap<String, Object> draft = newDraft.getDraft(); String createDraft = convertToString(draft); org.egov.pgrrest.read.persistence.entity.Draft draftEntity = org.egov.pgrrest.read.persistence.entity.Draft .builder() .serviceCode(newDraft.getServiceCode()) .tenantId(newDraft.getTenantId()) .userId(newDraft.getUserId()) .draft(createDraft) .build(); draftJpaRepository.save(draftEntity); return draftEntity.getId(); } DraftRepository(DraftJpaRepository draftJpaRepository, ObjectMapper objectMapper); long saveDraft(NewDraft newDraft); DraftResult getDrafts(DraftSearchCriteria searchCriteria); void delete(List<Long> draftIdList); void delete(long draftId); void updateDraft(UpdateDraft draftUpdateRequest);  }