@Test public void validateMuleArtifactMandatoryFieldsMissingTest() throws ValidationException { expectedException.expect(ValidationException.class); expectedException .expectMessage("The following mandatory fields in the mule-artifact.json are missing or invalid: [name, minMuleVersion, requiredProduct]"); MuleApplicationModel muleArtifact = new MuleApplicationModelJsonSerializer() .deserialize("{ }"); validateMuleArtifactMandatoryFields(muleArtifact, Optional.empty()); }
protected static void validateMuleArtifactMandatoryFields(MuleApplicationModel muleArtifact, Optional<String> deployMuleVersion) throws ValidationException { List<String> missingFields = new ArrayList<>(); checkName(muleArtifact, missingFields); checkMinMuleVersionValue(muleArtifact, missingFields, deployMuleVersion); checkRequiredProduct(muleArtifact, missingFields); if (!missingFields.isEmpty()) { String message = "The following mandatory fields in the mule-artifact.json are missing or invalid: " + missingFields; if (missingFields.contains("requiredProduct")) { message += ". requiredProduct valid values are: MULE, MULE_EE"; } throw new ValidationException(message); } }
MuleArtifactJsonValidator { protected static void validateMuleArtifactMandatoryFields(MuleApplicationModel muleArtifact, Optional<String> deployMuleVersion) throws ValidationException { List<String> missingFields = new ArrayList<>(); checkName(muleArtifact, missingFields); checkMinMuleVersionValue(muleArtifact, missingFields, deployMuleVersion); checkRequiredProduct(muleArtifact, missingFields); if (!missingFields.isEmpty()) { String message = "The following mandatory fields in the mule-artifact.json are missing or invalid: " + missingFields; if (missingFields.contains("requiredProduct")) { message += ". requiredProduct valid values are: MULE, MULE_EE"; } throw new ValidationException(message); } } }
MuleArtifactJsonValidator { protected static void validateMuleArtifactMandatoryFields(MuleApplicationModel muleArtifact, Optional<String> deployMuleVersion) throws ValidationException { List<String> missingFields = new ArrayList<>(); checkName(muleArtifact, missingFields); checkMinMuleVersionValue(muleArtifact, missingFields, deployMuleVersion); checkRequiredProduct(muleArtifact, missingFields); if (!missingFields.isEmpty()) { String message = "The following mandatory fields in the mule-artifact.json are missing or invalid: " + missingFields; if (missingFields.contains("requiredProduct")) { message += ". requiredProduct valid values are: MULE, MULE_EE"; } throw new ValidationException(message); } }  }
MuleArtifactJsonValidator { protected static void validateMuleArtifactMandatoryFields(MuleApplicationModel muleArtifact, Optional<String> deployMuleVersion) throws ValidationException { List<String> missingFields = new ArrayList<>(); checkName(muleArtifact, missingFields); checkMinMuleVersionValue(muleArtifact, missingFields, deployMuleVersion); checkRequiredProduct(muleArtifact, missingFields); if (!missingFields.isEmpty()) { String message = "The following mandatory fields in the mule-artifact.json are missing or invalid: " + missingFields; if (missingFields.contains("requiredProduct")) { message += ". requiredProduct valid values are: MULE, MULE_EE"; } throw new ValidationException(message); } }  static void validate(Path projectBaseDir, Optional<String> deployMuleVersion); static void isMuleArtifactJsonPresent(Path projectBaseDir); static void isMuleArtifactJsonValid(Path projectBaseDir, Optional<String> deployMuleVersion); }
MuleArtifactJsonValidator { protected static void validateMuleArtifactMandatoryFields(MuleApplicationModel muleArtifact, Optional<String> deployMuleVersion) throws ValidationException { List<String> missingFields = new ArrayList<>(); checkName(muleArtifact, missingFields); checkMinMuleVersionValue(muleArtifact, missingFields, deployMuleVersion); checkRequiredProduct(muleArtifact, missingFields); if (!missingFields.isEmpty()) { String message = "The following mandatory fields in the mule-artifact.json are missing or invalid: " + missingFields; if (missingFields.contains("requiredProduct")) { message += ". requiredProduct valid values are: MULE, MULE_EE"; } throw new ValidationException(message); } }  static void validate(Path projectBaseDir, Optional<String> deployMuleVersion); static void isMuleArtifactJsonPresent(Path projectBaseDir); static void isMuleArtifactJsonValid(Path projectBaseDir, Optional<String> deployMuleVersion);  }