@Test void getOperationsByTypeAndTppId() { when(userMgmtRestClient.getUser()).thenReturn(ResponseEntity.ok(getUser(UserRoleTO.STAFF))); when(infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(anyString(), any())).thenReturn(getOperationInfos()); when(infoMapper.toOperationInfos(anyList())).thenAnswer(a -> MAPPER.toOperationInfos(a.getArgument(0))); List<OperationInfo> result = service.getOperationsByTypeAndTppId(OperationType.CONSENT); assertEquals(MAPPER.toOperationInfos(getOperationInfos()), result); }
public List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType) { String tppId = validateAndGetTppId(); List<OperationInfoEntity> infos = Optional.ofNullable(operationType) .map(o -> infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(tppId, OperationTypeEntity.valueOf(o.name()))) .orElseGet(() -> infoRepository.findAllByTppIdOrderByCreatedDesc(tppId)); return infoMapper.toOperationInfos(infos); }
TppOperationInfoService { public List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType) { String tppId = validateAndGetTppId(); List<OperationInfoEntity> infos = Optional.ofNullable(operationType) .map(o -> infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(tppId, OperationTypeEntity.valueOf(o.name()))) .orElseGet(() -> infoRepository.findAllByTppIdOrderByCreatedDesc(tppId)); return infoMapper.toOperationInfos(infos); } }
TppOperationInfoService { public List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType) { String tppId = validateAndGetTppId(); List<OperationInfoEntity> infos = Optional.ofNullable(operationType) .map(o -> infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(tppId, OperationTypeEntity.valueOf(o.name()))) .orElseGet(() -> infoRepository.findAllByTppIdOrderByCreatedDesc(tppId)); return infoMapper.toOperationInfos(infos); }  }
TppOperationInfoService { public List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType) { String tppId = validateAndGetTppId(); List<OperationInfoEntity> infos = Optional.ofNullable(operationType) .map(o -> infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(tppId, OperationTypeEntity.valueOf(o.name()))) .orElseGet(() -> infoRepository.findAllByTppIdOrderByCreatedDesc(tppId)); return infoMapper.toOperationInfos(infos); }  List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType); OperationInfo createInfo(OperationInfo operationInfo); void deleteInfo(Long operationInfoId); }
TppOperationInfoService { public List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType) { String tppId = validateAndGetTppId(); List<OperationInfoEntity> infos = Optional.ofNullable(operationType) .map(o -> infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(tppId, OperationTypeEntity.valueOf(o.name()))) .orElseGet(() -> infoRepository.findAllByTppIdOrderByCreatedDesc(tppId)); return infoMapper.toOperationInfos(infos); }  List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType); OperationInfo createInfo(OperationInfo operationInfo); void deleteInfo(Long operationInfoId);  }