MuleArtifactJsonValidator { protected static void checkClassLoaderModelDescriptor(MuleApplicationModel muleArtifact, List<String> missingFields) { MuleArtifactLoaderDescriptor classLoaderModelDescriptor = muleArtifact.getClassLoaderModelLoaderDescriptor(); if (classLoaderModelDescriptor == null) { missingFields.add("classLoaderModelLoaderDescriptor"); } if (classLoaderModelDescriptor == null || StringUtils.isBlank(classLoaderModelDescriptor.getId())) { missingFields.add("classLoaderModelLoaderDescriptor.id"); } }  static void validate(Path projectBaseDir, Optional<String> deployMuleVersion); static void isMuleArtifactJsonPresent(Path projectBaseDir); static void isMuleArtifactJsonValid(Path projectBaseDir, Optional<String> deployMuleVersion);  }
@Test public void checkClassLoaderModelDescriptorMissingTest() throws IOException { MuleApplicationModel muleArtifact = new MuleApplicationModelJsonSerializer().deserialize("{ }"); checkClassLoaderModelDescriptor(muleArtifact, missingFields); assertThat("Missing fields should contain the classLoaderModelLoaderDescriptor and classLoaderModelLoaderDescriptor.id fields names", missingFields, containsInAnyOrder("classLoaderModelLoaderDescriptor", "classLoaderModelLoaderDescriptor.id")); }
@Test public void checkClassLoaderModelDescriptorMissingIdTest() throws IOException { MuleApplicationModel muleArtifact = new MuleApplicationModelJsonSerializer().deserialize("{ classLoaderModelLoaderDescriptor: {} }"); checkClassLoaderModelDescriptor(muleArtifact, missingFields); assertThat("There should be just one missing field", missingFields.size(), equalTo(1)); assertThat("Missing fields should contain the classLoaderModelLoaderDescriptor.id fields names", missingFields, containsInAnyOrder("classLoaderModelLoaderDescriptor.id")); }
@Test public void checkClassLoaderModelDescriptorTest() throws IOException { MuleApplicationModel muleArtifact = new MuleApplicationModelJsonSerializer().deserialize("{ classLoaderModelLoaderDescriptor: { id:mule } }"); checkClassLoaderModelDescriptor(muleArtifact, missingFields); assertThat("Missing fields should be empty", missingFields.isEmpty(), is(true)); }