@Test public void test_draft_repository_should_search_draft_with_service_code() { draftRepository.getDrafts(new DraftSearchCriteria(73L, "NOC", "default")); verify(draftJpaRepository).findByUserIdAndServiceCodeAndTenantId(73L, "NOC", "default"); }
public DraftResult getDrafts(DraftSearchCriteria searchCriteria) { List<org.egov.pgrrest.read.persistence.entity.Draft> entityDrafts = fetchDrafts(searchCriteria); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { }; List<Draft> drafts = entityDrafts.stream().map(draft -> { try { HashMap<String, Object> readValue = objectMapper.readValue(draft.getDraft(), typeReference); return new Draft(draft.getId(), readValue); } catch (IOException e) { throw new DraftReadException(e); } }).collect(Collectors.toList()); return DraftResult.builder().drafts(drafts).build(); }
DraftRepository { public DraftResult getDrafts(DraftSearchCriteria searchCriteria) { List<org.egov.pgrrest.read.persistence.entity.Draft> entityDrafts = fetchDrafts(searchCriteria); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { }; List<Draft> drafts = entityDrafts.stream().map(draft -> { try { HashMap<String, Object> readValue = objectMapper.readValue(draft.getDraft(), typeReference); return new Draft(draft.getId(), readValue); } catch (IOException e) { throw new DraftReadException(e); } }).collect(Collectors.toList()); return DraftResult.builder().drafts(drafts).build(); } }
DraftRepository { public DraftResult getDrafts(DraftSearchCriteria searchCriteria) { List<org.egov.pgrrest.read.persistence.entity.Draft> entityDrafts = fetchDrafts(searchCriteria); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { }; List<Draft> drafts = entityDrafts.stream().map(draft -> { try { HashMap<String, Object> readValue = objectMapper.readValue(draft.getDraft(), typeReference); return new Draft(draft.getId(), readValue); } catch (IOException e) { throw new DraftReadException(e); } }).collect(Collectors.toList()); return DraftResult.builder().drafts(drafts).build(); } DraftRepository(DraftJpaRepository draftJpaRepository, ObjectMapper objectMapper); }
DraftRepository { public DraftResult getDrafts(DraftSearchCriteria searchCriteria) { List<org.egov.pgrrest.read.persistence.entity.Draft> entityDrafts = fetchDrafts(searchCriteria); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { }; List<Draft> drafts = entityDrafts.stream().map(draft -> { try { HashMap<String, Object> readValue = objectMapper.readValue(draft.getDraft(), typeReference); return new Draft(draft.getId(), readValue); } catch (IOException e) { throw new DraftReadException(e); } }).collect(Collectors.toList()); return DraftResult.builder().drafts(drafts).build(); } 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 DraftResult getDrafts(DraftSearchCriteria searchCriteria) { List<org.egov.pgrrest.read.persistence.entity.Draft> entityDrafts = fetchDrafts(searchCriteria); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { }; List<Draft> drafts = entityDrafts.stream().map(draft -> { try { HashMap<String, Object> readValue = objectMapper.readValue(draft.getDraft(), typeReference); return new Draft(draft.getId(), readValue); } catch (IOException e) { throw new DraftReadException(e); } }).collect(Collectors.toList()); return DraftResult.builder().drafts(drafts).build(); } 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);  }