@Test public void testValidateExpression_successful() { Expression expression = new Expression(); expression.setOperator(Operator.AND); List<Operand> operandsList = new ArrayList<>(); Operand operand1 = new Operand(); Operand operand2 = new Operand(); Operand operand3 = new Operand(); Field field1 = new Field(); field1.setKey("name"); field1.setValue("sample-app"); Field field2 = new Field(); field2.setKey("env"); field2.setValue("prod"); Field field3 = new Field(); field3.setKey("type"); field3.setValue("gauge"); operand1.setField(field1); operand2.setField(field2); operand3.setField(field3); operandsList.add(operand1); operandsList.add(operand2); expression.setOperands(operandsList); RequestValidator.validateExpression(expression); }
public static void validateExpression(Expression expression) { Assert.notNull(expression, "subscription expression can't null"); Assert.isTrue(Operator.AND.equals(expression.getOperator()), "Only AND operator is supported now"); Assert.notEmpty(expression.getOperands(), "Operands can't be empty"); expression.getOperands().forEach(operand -> validateOperand(operand)); }
RequestValidator { public static void validateExpression(Expression expression) { Assert.notNull(expression, "subscription expression can't null"); Assert.isTrue(Operator.AND.equals(expression.getOperator()), "Only AND operator is supported now"); Assert.notEmpty(expression.getOperands(), "Operands can't be empty"); expression.getOperands().forEach(operand -> validateOperand(operand)); } }
RequestValidator { public static void validateExpression(Expression expression) { Assert.notNull(expression, "subscription expression can't null"); Assert.isTrue(Operator.AND.equals(expression.getOperator()), "Only AND operator is supported now"); Assert.notEmpty(expression.getOperands(), "Operands can't be empty"); expression.getOperands().forEach(operand -> validateOperand(operand)); }  }
RequestValidator { public static void validateExpression(Expression expression) { Assert.notNull(expression, "subscription expression can't null"); Assert.isTrue(Operator.AND.equals(expression.getOperator()), "Only AND operator is supported now"); Assert.notEmpty(expression.getOperands(), "Operands can't be empty"); expression.getOperands().forEach(operand -> validateOperand(operand)); }  static void validateUser(User user); static void validateExpression(Expression expression); static void validateBoolean(Boolean condition); static void validateMappingDetector(ConsumerDetectorMapping consumerDetectorMapping); static void validateDetectorDocument(DetectorDocument document); static void validateDetector(Detector detector); }
RequestValidator { public static void validateExpression(Expression expression) { Assert.notNull(expression, "subscription expression can't null"); Assert.isTrue(Operator.AND.equals(expression.getOperator()), "Only AND operator is supported now"); Assert.notEmpty(expression.getOperands(), "Operands can't be empty"); expression.getOperands().forEach(operand -> validateOperand(operand)); }  static void validateUser(User user); static void validateExpression(Expression expression); static void validateBoolean(Boolean condition); static void validateMappingDetector(ConsumerDetectorMapping consumerDetectorMapping); static void validateDetectorDocument(DetectorDocument document); static void validateDetector(Detector detector);  }