Search in sources :

Example 1 with BlueOceanUrlMapper

use of io.jenkins.blueocean.rest.factory.BlueOceanUrlMapper in project blueocean-plugin by jenkinsci.

the class StatePreloaderTest method test.

@Test
public void test() throws IOException, ExecutionException, InterruptedException, SAXException {
    // Create a project and run a build on it.
    FreeStyleProject freestyleProject = j.createProject(FreeStyleProject.class, "freestyle");
    FreeStyleBuild run = freestyleProject.scheduleBuild2(0).get();
    j.waitForCompletion(run);
    // Lets request the activity page for that project. The page should
    // contain some prefetched javascript for the pipeline
    // details + the runs on the page
    Assert.assertTrue(BlueOceanUrlMapper.all().size() > 0);
    BlueOceanUrlMapper mapper = BlueOceanUrlMapper.all().get(0);
    String projectBlueUrl = j.jenkins.getRootUrl() + mapper.getUrl(freestyleProject);
    Document doc = Jsoup.connect(projectBlueUrl + "/activity/").get();
    String script = doc.select("head script").toString();
    Assert.assertTrue(script.contains(String.format("setState('prefetchdata.%s',", PipelineStatePreloader.class.getSimpleName())));
    Assert.assertTrue(script.contains(String.format("setState('prefetchdata.%s',", PipelineActivityStatePreloader.class.getSimpleName())));
    Assert.assertTrue(script.contains("\"restUrl\":\"/blue/rest/organizations/jenkins/pipelines/freestyle/runs/?start=0&limit=26\""));
}
Also used : BlueOceanUrlMapper(io.jenkins.blueocean.rest.factory.BlueOceanUrlMapper) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Document(org.jsoup.nodes.Document) PipelineBaseTest(io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest) Test(org.junit.Test)

Aggregations

FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProject (hudson.model.FreeStyleProject)1 BlueOceanUrlMapper (io.jenkins.blueocean.rest.factory.BlueOceanUrlMapper)1 PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)1 Document (org.jsoup.nodes.Document)1 Test (org.junit.Test)1