### Question:
UtilsConfig { public String generateFilter(Translate translate) { StringBuilder sb = new StringBuilder(); if (translate.getTypeCondition() != null) { if (translate.getTypeCondition().getCheckPresent()) { if (translate.getTypeCondition().getIsPresence()) { sb.append(" if [" + translate.getTypeCondition().getCondition()); } else { sb.append(" if ![" + translate.getTypeCondition().getCondition()); } sb.append("] {" + RETURN); sb.append(filterAction(translate)); sb.append(RETURN_BRACE); } else { if (!translate.getTypeCondition().getIsPresence()) { sb.append(filterAction(translate)); } else { sb.append(" if [" + translate.getTypeCondition().getCondition() + "] {" + RETURN); sb.append(filterAction(translate)); sb.append(RETURN_BRACE); } } } else { sb.append(filterAction(translate)); } return sb.toString(); }  String generateConfig(ConfigurationLogstash cl); String filterAction(Translate translate); String generateFilter(Translate translate); String generateOutput(ConfigurationOutput output); String generateInput(ConfigurationHost input);  }### Answer:
@Test public void filter_CondNull() { String result = utilsConfig.generateFilter(generateFilterTranslate(TypeFilter.GROK, null)); assertThat(result).isEqualTo(" grok { match => {\"keyTranslate\" => \"MYPATTERN2\"} }\n"); }
@Test public void filter_CondNotNullButCheckTrue() { String result = utilsConfig.generateFilter(generateFilterTranslate(TypeFilter.GROK, TypeCondition.builder().condition("condition").checkPresent(true).isPresence(true).build())); assertThat(result).isEqualTo(" if [condition] { \n grok { match => {\"keyTranslate\" => \"MYPATTERN2\"} }\n }\n"); }
@Test public void filter_CondNotNullButCheckFalse() { String result = utilsConfig.generateFilter(generateFilterTranslate(TypeFilter.GROK, TypeCondition.builder().condition("condition").checkPresent(true).isPresence(false).build())); assertThat(result).isEqualTo(" if ![condition] { \n grok { match => {\"keyTranslate\" => \"MYPATTERN2\"} }\n }\n"); }