use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method detectsInvalidClassLoaderModelLoaderId.
@Test
public void detectsInvalidClassLoaderModelLoaderId() throws Exception {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(INVALID_LOADER_ID, emptyMap()));
PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).describedBy(mulePolicyModelBuilder.build());
File tempFolder = createTempFolder();
unzip(policyFileBuilder.getArtifactFile(), tempFolder);
PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
expectedException.expect(ArtifactDescriptorCreateException.class);
expectedException.expectMessage(invalidClassLoaderModelIdError(tempFolder, mulePolicyModelBuilder.getClassLoaderModelDescriptorLoader()));
descriptorFactory.create(tempFolder, empty());
}
use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method assignsBundleDescriptor.
@Test
public void assignsBundleDescriptor() throws Exception {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).usingLibrary(echoTestJarFile.getAbsolutePath()).describedBy(mulePolicyModelBuilder.build());
File tempFolder = createTempFolder();
unzip(policyFileBuilder.getArtifactFile(), tempFolder);
PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
PolicyTemplateDescriptor desc = descriptorFactory.create(tempFolder, empty());
assertThat(desc.getBundleDescriptor().getArtifactId(), equalTo(POLICY_NAME));
assertThat(desc.getBundleDescriptor().getGroupId(), equalTo(POLICY_GROUP_ID));
assertThat(desc.getBundleDescriptor().getClassifier().get(), equalTo(POLICY_CLASSIFIER));
assertThat(desc.getBundleDescriptor().getType(), equalTo(POLICY_ARTIFACT_TYPE));
assertThat(desc.getBundleDescriptor().getVersion(), equalTo(POLICY_VERSION));
}
Aggregations