Search in sources :

Example 56 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class KarafFeaturesPropertiesFileResolver method uris.

/**
 * Returns a map of groupId/artifactId -> artifact
 * @param uriStringsFromPatch
 * @return
 */
private Map<String, Artifact> uris(List<String> uriStringsFromPatch) {
    Map<String, Artifact> result = new LinkedHashMap<>();
    for (String uri : uriStringsFromPatch) {
        Artifact a = Utils.mvnurlToArtifact(uri, true);
        if (a == null) {
            continue;
        }
        String ga = String.format("%s/%s", a.getGroupId(), a.getArtifactId());
        result.put(ga, a);
    }
    return result;
}
Also used : Artifact(io.fabric8.patch.management.Artifact) LinkedHashMap(java.util.LinkedHashMap)

Example 57 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class SimulateAction method doExecute.

@Override
protected void doExecute(Service service) throws Exception {
    Patch patch = service.getPatch(patchId);
    if (patch == null) {
        throw new PatchException("Patch '" + patchId + "' not found");
    }
    if (patch.isInstalled()) {
        throw new PatchException("Patch '" + patchId + "' is already installed");
    }
    PatchResult result = service.install(patch, true);
// display(result);
}
Also used : PatchResult(io.fabric8.patch.management.PatchResult) PatchException(io.fabric8.patch.management.PatchException) Patch(io.fabric8.patch.management.Patch)

Example 58 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class ArchetypeXmlTest method testMarshalArchetypes.

@Test
public void testMarshalArchetypes() throws JAXBException {
    Archetypes archetypes = new Archetypes();
    archetypes.add(new Archetype("foo", "bar", "1.1", "Some name", "Some description"));
    archetypes.add(new Archetype("xyz", "whatever", "2.3", "Some other name", "Docs..."));
    StringWriter buffer = new StringWriter();
    Archetypes.newMarshaller().marshal(archetypes, buffer);
    System.out.println("Generated XML: " + buffer);
    Object result = Archetypes.newUnmarshaller().unmarshal(new StringReader(buffer.toString()));
    if (result instanceof Archetypes) {
        assertEquals(2, ((Archetypes) result).getArchetypes().size());
        for (Archetype a : ((Archetypes) result).getArchetypes()) {
            System.out.println(a);
        }
    } else {
        fail("Found " + result.getClass().getName() + " when expected an " + Archetypes.class.getName());
    }
}
Also used : StringWriter(java.io.StringWriter) Archetype(io.fabric8.tooling.archetype.catalog.Archetype) StringReader(java.io.StringReader) Archetypes(io.fabric8.tooling.archetype.catalog.Archetypes) Test(org.junit.Test)

Example 59 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.

the class DockerBuildServiceTest method testSuccessfulBuild.

@Test
public void testSuccessfulBuild() throws Exception {
    new Expectations() {

        {
            hub.getBuildService();
            result = buildService;
        }
    };
    final BuildService.BuildContext context = new BuildService.BuildContext.Builder().build();
    final io.fabric8.maven.core.service.BuildService.BuildServiceConfig config = new io.fabric8.maven.core.service.BuildService.BuildServiceConfig.Builder().dockerBuildContext(context).build();
    final String imageName = "image-name";
    final ImageConfiguration image = new ImageConfiguration.Builder().name(imageName).buildConfig(new BuildImageConfiguration.Builder().from("from").build()).build();
    DockerBuildService service = new DockerBuildService(hub, config);
    service.build(image);
    new FullVerificationsInOrder() {

        {
            buildService.buildImage(image, context);
            buildService.tagImage(imageName, image);
        }
    };
}
Also used : Expectations(mockit.Expectations) BuildService(io.fabric8.maven.docker.service.BuildService) FullVerificationsInOrder(mockit.FullVerificationsInOrder) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) Test(org.junit.Test)

Example 60 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.

the class OpenshiftBuildServiceTest method init.

@Before
public void init() throws Exception {
    final File dockerFile = new File(baseDir, "Docker.tar");
    dockerFile.getParentFile().mkdirs();
    dockerFile.createNewFile();
    imageStreamFile.delete();
    new Expectations() {

        {
            dockerServiceHub.getArchiveService();
            result = archiveService;
            archiveService.createDockerBuildArchive(withAny(ImageConfiguration.class.cast(null)), withAny(MojoParameters.class.cast(null)));
            result = dockerFile;
            minTimes = 0;
            project.getArtifact();
            result = "myapp";
            minTimes = 0;
            dockerMojoParameters.getProject();
            result = project;
            minTimes = 0;
        }
    };
    image = new ImageConfiguration.Builder().name(projectName).buildConfig(new BuildImageConfiguration.Builder().from(projectName).build()).build();
    defaultConfig = new BuildService.BuildServiceConfig.Builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).s2iBuildNameSuffix("-s2i-suffix2").openshiftBuildStrategy(OpenShiftBuildStrategy.s2i).dockerMojoParameters(dockerMojoParameters);
}
Also used : Expectations(mockit.Expectations) BuildService(io.fabric8.maven.core.service.BuildService) ImageStreamStatusBuilder(io.fabric8.openshift.api.model.ImageStreamStatusBuilder) BuildBuilder(io.fabric8.openshift.api.model.BuildBuilder) NamedTagEventListBuilder(io.fabric8.openshift.api.model.NamedTagEventListBuilder) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) BuildConfigBuilder(io.fabric8.openshift.api.model.BuildConfigBuilder) File(java.io.File) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)104 Expectations (mockit.Expectations)49 HashMap (java.util.HashMap)32 Map (java.util.Map)24 ArrayList (java.util.ArrayList)23 File (java.io.File)21 GitContext (io.fabric8.api.GitContext)20 IOException (java.io.IOException)20 Exchange (org.apache.camel.Exchange)20 Processor (org.apache.camel.Processor)20 DefaultPullPushPolicy (io.fabric8.git.internal.DefaultPullPushPolicy)18 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)17 Probe (io.fabric8.kubernetes.api.model.Probe)16 PatchResult (io.fabric8.patch.management.PatchResult)13 Properties (java.util.Properties)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)11 Patch (io.fabric8.patch.management.Patch)11 PatchException (io.fabric8.patch.management.PatchException)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 TreeMap (java.util.TreeMap)10