@Test void translateShouldNotThrowWhenPassingNullOperator() { String nullOperator = null; assertThatCode(() -> queryTranslator.translate(new QueryDTO(nullOperator, ImmutableList.of()))) .doesNotThrowAnyException(); }
private Criterion<?> translate(CriterionDTO dto) throws QueryTranslatorException { return Optional.ofNullable(getCriterionParser(dto)) .map(criterionGeneratingFunction -> criterionGeneratingFunction.apply(dto.getValue())) .orElseThrow(() -> new QueryTranslatorException("pair of fieldName: '" + dto.getFieldName() + "' and operator: '" + dto.getOperator() + "' is not supported")); }
QueryTranslator { private Criterion<?> translate(CriterionDTO dto) throws QueryTranslatorException { return Optional.ofNullable(getCriterionParser(dto)) .map(criterionGeneratingFunction -> criterionGeneratingFunction.apply(dto.getValue())) .orElseThrow(() -> new QueryTranslatorException("pair of fieldName: '" + dto.getFieldName() + "' and operator: '" + dto.getOperator() + "' is not supported")); } }
QueryTranslator { private Criterion<?> translate(CriterionDTO dto) throws QueryTranslatorException { return Optional.ofNullable(getCriterionParser(dto)) .map(criterionGeneratingFunction -> criterionGeneratingFunction.apply(dto.getValue())) .orElseThrow(() -> new QueryTranslatorException("pair of fieldName: '" + dto.getFieldName() + "' and operator: '" + dto.getOperator() + "' is not supported")); } @Inject @VisibleForTesting  QueryTranslator(MailboxId.Factory mailboxIdFactory); }
QueryTranslator { private Criterion<?> translate(CriterionDTO dto) throws QueryTranslatorException { return Optional.ofNullable(getCriterionParser(dto)) .map(criterionGeneratingFunction -> criterionGeneratingFunction.apply(dto.getValue())) .orElseThrow(() -> new QueryTranslatorException("pair of fieldName: '" + dto.getFieldName() + "' and operator: '" + dto.getOperator() + "' is not supported")); } @Inject @VisibleForTesting  QueryTranslator(MailboxId.Factory mailboxIdFactory); static FieldName getField(String fieldNameString); Query translate(QueryElement queryElement); QueryDTO toDTO(Query query); }
QueryTranslator { private Criterion<?> translate(CriterionDTO dto) throws QueryTranslatorException { return Optional.ofNullable(getCriterionParser(dto)) .map(criterionGeneratingFunction -> criterionGeneratingFunction.apply(dto.getValue())) .orElseThrow(() -> new QueryTranslatorException("pair of fieldName: '" + dto.getFieldName() + "' and operator: '" + dto.getOperator() + "' is not supported")); } @Inject @VisibleForTesting  QueryTranslator(MailboxId.Factory mailboxIdFactory); static FieldName getField(String fieldNameString); Query translate(QueryElement queryElement); QueryDTO toDTO(Query query);  }