org.jvnet.hudson.test.recipes.LocalData Java Examples

The following examples show how to use org.jvnet.hudson.test.recipes.LocalData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AggregatedTestResultPublisherTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@LocalData
@Test
public void aggregatedTestResultsOnly() throws Exception {
    createUpstreamProjectWithNoTests();
    createDownstreamProjectWithTests();

    buildAndSetupPageObjects();

    projectPage.getLatestAggregatedTestReportLink()
            .assertHasLatestAggregatedTestResultText()
            .assertHasTests()
            .follow().hasLinkToTestResultOfBuild(TEST_PROJECT_NAME, 1);

    projectPage.assertNoTestReportLink();

    buildPage.getAggregatedTestReportLink()
            .assertHasAggregatedTestResultText()
            .assertHasTests()
            .follow().hasLinkToTestResultOfBuild(TEST_PROJECT_NAME, 1);
    buildPage.assertNoTestReportLink();
}
 
Example #2
Source File: JUnitResultArchiverTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@LocalData("All")
@Test public void setDescription() throws Exception {
    FreeStyleBuild build = project.scheduleBuild2(0).get(10, TimeUnit.SECONDS);

    CaseResult caseResult = build.getAction(TestResultAction.class).getFailedTests().get(0);
    String url = build.getUrl() + "/testReport/" + caseResult.getRelativePathFrom(caseResult.getTestResult());

    testSetDescription(url, caseResult);

    ClassResult classResult = caseResult.getParent();
    url = build.getUrl() + "/testReport/" + classResult.getParent().getSafeName() + "/" + classResult.getSafeName();
    testSetDescription(url, classResult);

    PackageResult packageResult = classResult.getParent();
    url = build.getUrl() + "/testReport/" + classResult.getParent().getSafeName();
    testSetDescription(url, packageResult);

}
 
Example #3
Source File: JUnitResultArchiverTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@LocalData("All")
@Test public void basic() throws Exception {
    FreeStyleBuild build = project.scheduleBuild2(0).get(10, TimeUnit.SECONDS);

    assertTestResults(build);

    WebClient wc = j.new WebClient();
    wc.getPage(project); // project page
    wc.getPage(build); // build page
    wc.getPage(build, "testReport");  // test report
    wc.getPage(build, "testReport/hudson.security"); // package
    wc.getPage(build, "testReport/hudson.security/HudsonPrivateSecurityRealmTest/"); // class
    wc.getPage(build, "testReport/hudson.security/HudsonPrivateSecurityRealmTest/testDataCompatibilityWith1_282/"); // method


}
 
Example #4
Source File: TestResultPublishingTest.java    From junit-plugin with MIT License 6 votes vote down vote up
/**
 * Test to demonstrate bug HUDSON-5246, inter-build diffs for junit test results are wrong
 */
@Issue("JENKINS-5246")
@LocalData
@Test
public void testInterBuildDiffs() throws IOException, SAXException {
    Project proj = (Project)rule.jenkins.getItem(TEST_PROJECT_WITH_HISTORY);
    assertNotNull("We should have a project named " + TEST_PROJECT_WITH_HISTORY, proj);

    // Validate that there are test results where I expect them to be:
    WebClient wc = rule.createWebClient();
    Run theRun = proj.getBuildByNumber(4);
    assertTestResultsAsExpected(wc, theRun, "/testReport",
                    "org.jvnet.hudson.examples.small", "12 ms", "FAILURE",
                    /* total tests expected, diff */ 3, 0,
                    /* fail count expected, diff */ 1, 0,
                    /* skip count expected, diff */ 0, 0);


}
 
Example #5
Source File: DockerCloudRetentionStrategyTest.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
@LocalData
@Test
public void testConfig() {
    final Cloud cloud = jenkinsRule.getInstance().getCloud("ff");
    assertThat(cloud, instanceOf(DockerCloud.class));

    final DockerCloud dockerCloud = (DockerCloud) cloud;
    final DockerSlaveTemplate template = dockerCloud.getTemplate("image");
    assertThat(template, notNullValue());

    final RetentionStrategy retentionStrategy = template.getRetentionStrategy();
    assertThat(retentionStrategy, instanceOf(DockerCloudRetentionStrategy.class));

    final DockerCloudRetentionStrategy strategy = (DockerCloudRetentionStrategy) retentionStrategy;
    assertThat(strategy.getIdleMinutes(), is(30));
}
 
Example #6
Source File: DockerComputerSSHLauncherTest.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
@LocalData
@Test
public void migration() {
    Cloud cl = jenkinsRule.getInstance().getCloud("cloudName");
    assertThat(cl, notNullValue());

    DockerCloud cloud = (DockerCloud) cl;
    assertThat(cloud, notNullValue());

    DockerSlaveTemplate template = cloud.getTemplateById("fb5f32a8-bfdd-4f00-8df8-fcf3cf14ab63");
    assertThat(template, notNullValue());

    DockerComputerLauncher l = template.getLauncher();
    assertThat(l, instanceOf(DockerComputerSSHLauncher.class));
    DockerComputerSSHLauncher sshLauncher = (DockerComputerSSHLauncher) l;

    DockerSSHConnector dockerSSHConnector = sshLauncher.getSshConnector();
    assertThat(dockerSSHConnector, notNullValue());

    assertThat(dockerSSHConnector.getSshHostKeyVerificationStrategy(), notNullValue());
    assertThat(dockerSSHConnector.getSshHostKeyVerificationStrategy(), instanceOf(KnownHostsFileKeyVerificationStrategy.class));
    assertThat(dockerSSHConnector.getSuffixStartSlaveCmd(), is("suffixStartSlave"));
    assertThat(dockerSSHConnector.getPrefixStartSlaveCmd(), is("prefixStartSlave"));


}
 
Example #7
Source File: MongoRepositoryTest.java    From DotCi with MIT License 6 votes vote down vote up
@Test
@LocalData
public void should_save_a_project() throws Exception {
    DynamicProjectRepository repo = SetupConfig.get().getDynamicProjectRepository();

    GHRepository ghRepository = setupMockGHRepository();

    DynamicProject project = repo.createNewProject(ghRepository, null, null);

    project.addProperty(new CyclicProperty(project));
    project.save();

    assertTrue(repo.getDatastore().getCount(DynamicProject.class) > 0);
    DynamicProject restoredProject = repo.getDatastore().createQuery(DynamicProject.class).get();

    assertEquals("repo_name", restoredProject.getName());
}
 
Example #8
Source File: TestResultLinksTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@LocalData
@Test
public void testNonDescendantRelativePath() throws Exception {
    FreeStyleBuild build = project.scheduleBuild2(0).get(10, TimeUnit.MINUTES); // leave time for interactive debugging
    rule.assertBuildStatus(Result.UNSTABLE, build);
    TestResult theOverallTestResult =   build.getAction(TestResultAction.class).getResult();
    CaseResult theFailedTestCase = theOverallTestResult.getFailedTests().get(0);
    String relativePath = theFailedTestCase.getRelativePathFrom(theOverallTestResult);
    System.out.println("relative path seems to be: " + relativePath);
    assertNotNull("relative path exists", relativePath);
    assertFalse("relative path doesn't start with a slash", relativePath.startsWith("/"));

    // Now ask for the relative path from the child to the parent -- we should get an absolute path
    String relativePath2 = theOverallTestResult.getRelativePathFrom(theFailedTestCase);
    System.out.println("relative path2 seems to be: " + relativePath2);
    // I know that in a HudsonTestCase we don't have a meaningful root url, so I expect an empty string here.
    // If somehow we start being able to produce a root url, then I'll also tolerate a url that starts with that.
    boolean pathIsEmptyOrNull = relativePath2 == null || relativePath2.isEmpty();
    boolean pathStartsWithRootUrl = !pathIsEmptyOrNull && relativePath2.startsWith(rule.jenkins.getRootUrl());
    assertTrue("relative path is empty OR begins with the app root", pathIsEmptyOrNull || pathStartsWithRootUrl ); 
}
 
Example #9
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 6 votes vote down vote up
@Test
@LocalData
public void should_create_a_new_project() throws Exception {
    GHRepository ghRepository = mock(GHRepository.class);
    when(ghRepository.getHtmlUrl()).thenReturn(new URL("http://github.com/meow"));
    GHUser ghUser = mock(GHUser.class);
    when(ghUser.getLogin()).thenReturn("test_user");
    when(ghRepository.getOwner()).thenReturn(ghUser);
    when(ghRepository.getName()).thenReturn("test_job");

    int totalBefore = (int) repo.getDatastore().createQuery(DynamicProject.class).countAll();

    DynamicProject project = repo.createNewProject(ghRepository, "test", "username");
    assertNotNull(project);
    DynamicProject retrieved = repo.getProjectById(project.getId());
    assertNotNull(retrieved);
    int totalAfter = (int) repo.getDatastore().createQuery(DynamicProject.class).countAll();
    assertEquals(totalAfter, totalBefore + 1);
}
 
Example #10
Source File: AggregatedTestResultPublisherTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@LocalData
@Test
public void testResultsOnly() throws Exception {
    createUpstreamProjectWithTests();
    createDownstreamProjectWithNoTests();

    buildAndSetupPageObjects();

    projectPage.getLatestTestReportLink()
            .assertHasLatestTestResultText()
            .assertHasTests()
            .follow();
    projectPage.getLatestAggregatedTestReportLink()
            .assertHasLatestAggregatedTestResultText()
            .assertNoTests()
            .follow();

    buildPage.getTestReportLink()
            .assertHasTestResultText()
            .assertHasTests()
            .follow();
    buildPage.getAggregatedTestReportLink()
            .assertHasAggregatedTestResultText()
            .assertNoTests()
            .follow();
}
 
Example #11
Source File: GlobalConfigTest.java    From docker-workflow-plugin with MIT License 6 votes vote down vote up
@Issue("https://github.com/jenkinsci/docker-workflow-plugin/pull/202#issuecomment-597156438")
@LocalData
@Test
public void oldPackages() {
    story.then(r -> {
        assertEquals("GlobalConfig is translated", "docker", GlobalConfig.get().getDockerLabel());
        assertEquals("https://myreg/", GlobalConfig.get().getRegistry().getUrl());
        assertEquals("myreg", GlobalConfig.get().getRegistry().getCredentialsId());
        Folder d = r.jenkins.getItemByFullName("d", Folder.class);
        assertNotNull(d);
        FolderConfig c = d.getProperties().get(FolderConfig.class);
        assertNotNull("FolderConfig is translated", c);
        assertEquals("dokker", c.getDockerLabel());
        assertEquals("https://yourreg/", c.getRegistry().getUrl());
        assertEquals("yourreg", c.getRegistry().getCredentialsId());
        assertEquals("there is no old data", Collections.emptySet(), ExtensionList.lookupSingleton(OldDataMonitor.class).getData().keySet());
    });
}
 
Example #12
Source File: MongoRepositoryTest.java    From DotCi with MIT License 6 votes vote down vote up
@Test
@LocalData
public void should_save_mixed_type_lists() {
    MixedTypeListClass mixed = new MixedTypeListClass();
    Serializable[] mixedList = {1, "teststring", new DummySerialiazable()};
    mixed.mixedTypeList = mixedList;
    Datastore ds = SetupConfig.get().getInjector().getInstance(Datastore.class);
    ds.save(mixed);
    MixedTypeListClass restoredMixed = ds.createQuery(MixedTypeListClass.class).get();

    assertEquals(1, restoredMixed.mixedTypeList[0]);
    assertEquals("teststring", restoredMixed.mixedTypeList[1]);
    assertNotNull(restoredMixed.mixedTypeList[2]);
    assertTrue(restoredMixed.mixedTypeList[2] instanceof DummySerialiazable);
    DummySerialiazable dummy = (DummySerialiazable) restoredMixed.mixedTypeList[2];
    assertEquals("test", dummy.test);
}
 
Example #13
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData
public void upgradeFrom_1_15_9() {
    List<PodTemplate> templates = cloud.getTemplates();
    assertPodTemplates(templates);
    PodTemplate template = templates.get(0);
    assertEquals("blah", template.getYaml());
    assertEquals(Collections.singletonList("blah"), template.getYamls());
    assertNull(template._getYamls());
}
 
Example #14
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData()
@Issue("JENKINS-57116")
public void upgradeFrom_1_15_1() throws Exception {
    List<PodTemplate> templates = cloud.getTemplates();
    assertPodTemplates(templates);
    PodTemplate template = templates.get(0);
    assertEquals(Collections.emptyList(), template.getYamls());
    assertNull(template.getYaml());
}
 
Example #15
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData()
public void upgradeFrom_0_10() throws Exception {
    List<PodTemplate> templates = cloud.getTemplates();
    PodTemplate template = templates.get(0);
    DescribableList<NodeProperty<?>,NodePropertyDescriptor> nodeProperties = template.getNodeProperties();
    assertEquals(1, nodeProperties.size());
    ToolLocationNodeProperty property = (ToolLocationNodeProperty) nodeProperties.get(0);
    assertEquals(1, property.getLocations().size());
    ToolLocation location = property.getLocations().get(0);
    assertEquals("Default", location.getName());
    assertEquals("/custom/path", location.getHome());
    assertEquals(GitTool.class, location.getType().clazz);
    assertEquals(cloud.DEFAULT_WAIT_FOR_POD_SEC, cloud.getWaitForPodSec());
}
 
Example #16
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData()
public void upgradeFrom_0_12() throws Exception {
    List<PodTemplate> templates = cloud.getTemplates();
    assertPodTemplates(templates);
    PodTemplate template = templates.get(0);
    assertEquals(Arrays.asList(new KeyValueEnvVar("pod_a_key", "pod_a_value"),
            new KeyValueEnvVar("pod_b_key", "pod_b_value")), template.getEnvVars());
    assertEquals(Collections.emptyList(), template.getYamls());
    assertEquals(cloud.DEFAULT_WAIT_FOR_POD_SEC, cloud.getWaitForPodSec());
}
 
Example #17
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData()
public void upgradeFrom_1_1() throws Exception {
    List<Credentials> credentials = SystemCredentialsProvider.getInstance().getCredentials();
    assertEquals(3, credentials.size());
    UsernamePasswordCredentialsImpl cred0 = (UsernamePasswordCredentialsImpl) credentials.get(0);
    assertEquals("token", cred0.getId());
    assertEquals("myusername", cred0.getUsername());
    FileSystemServiceAccountCredential cred1 = (FileSystemServiceAccountCredential) credentials.get(1);
    StringCredentialsImpl cred2 = (StringCredentialsImpl) credentials.get(2);
    assertEquals("mytoken", Secret.toString(cred2.getSecret()));
    assertThat(cloud.getLabels(), hasEntry("jenkins", "slave"));
    assertEquals(cloud.DEFAULT_WAIT_FOR_POD_SEC, cloud.getWaitForPodSec());
}
 
Example #18
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData()
public void upgradeFrom_1_10() throws Exception {
    List<PodTemplate> templates = cloud.getTemplates();
    assertPodTemplates(templates);
    assertEquals(new Never(), cloud.getPodRetention());
    PodTemplate template = templates.get(0);
    assertEquals(new Default(), template.getPodRetention());
    assertEquals(cloud.DEFAULT_WAIT_FOR_POD_SEC, cloud.getWaitForPodSec());
    assertTrue(template.isShowRawYaml());
    assertEquals(Collections.emptyList(), template.getYamls());
    assertNull(template.getYaml());
}
 
Example #19
Source File: JUnitResultArchiverTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@RandomlyFails("TimeoutException from basic")
@LocalData("All")
@Test public void slave() throws Exception {
     DumbSlave s = j.createOnlineSlave();
     project.setAssignedLabel(s.getSelfLabel());

     FilePath src = new FilePath(j.jenkins.getRootPath(), "jobs/junit/workspace/");
     assertNotNull(src);
     FilePath dest = s.getWorkspaceFor(project);
     assertNotNull(dest);
     src.copyRecursiveTo("*.xml", dest);

     basic();
 }
 
Example #20
Source File: MongoRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
@Ignore
public void should_save_a_build() throws Exception {

    GHRepository ghRepository = setupMockGHRepository();

    DynamicProjectRepository repo = SetupConfig.get().getDynamicProjectRepository();
    DynamicProject project = repo.createNewProject(ghRepository, null, null);

    project.scheduleBuild2(0).get();

    assert (repo.getDatastore().getCount(DbBackedBuild.class) > 0);

    for (DbBackedBuild build : SetupConfig.get().getDynamicBuildRepository().getBuilds(project)) {
        assertNotNull(build.getParent());
        assertNotNull(build.getState());
        assertNotNull(build.getResult());
        assertNotNull(build.getNumber());
        assertNotNull(build.getCurrentBranch());
        assertNotNull(build.getPusher());
        assertNotNull(build.getSha());
        assertNotNull(build.getBuiltOn());
        assertNotNull(build.getTime());
    }

}
 
Example #21
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
public void should_check_if_a_project_exists() throws Exception {
    GHRepository ghRepository = mock(GHRepository.class);
    GHUser ghUser = mock(GHUser.class);
    when(ghUser.getLogin()).thenReturn("test_user");
    when(ghRepository.getOwner()).thenReturn(ghUser);
    when(ghRepository.getName()).thenReturn("test_job");

    assertTrue(repo.projectExists(ghRepository));
}
 
Example #22
Source File: TestResultPublishingTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@LocalData
@Test
public void testBasic() throws Exception {
    FreeStyleBuild build = project.scheduleBuild2(0).get(30, TimeUnit.SECONDS);

    assertTestResults(build);

    WebClient wc = rule.createWebClient();
    wc.getPage(project); // project page
    wc.getPage(build); // build page
    wc.getPage(build, "testReport");  // test report
    wc.getPage(build, "testReport/hudson.security"); // package
    wc.getPage(build, "testReport/hudson.security/HudsonPrivateSecurityRealmTest/"); // class
    wc.getPage(build, "testReport/hudson.security/HudsonPrivateSecurityRealmTest/testDataCompatibilityWith1_282/"); // method
}
 
Example #23
Source File: TestResultPublishingTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@LocalData
@Test
public void testSlave() throws Exception {
    DumbSlave s = rule.createOnlineSlave();
    project.setAssignedLabel(s.getSelfLabel());

    FilePath src = new FilePath(rule.jenkins.getRootPath(), "jobs/" + BASIC_TEST_PROJECT + "/workspace/");
    assertNotNull(src);
    FilePath dest = s.getWorkspaceFor(project);
    assertNotNull(dest);
    src.copyRecursiveTo("*.xml", dest);

    testBasic();
}
 
Example #24
Source File: TestResultPublishingTest.java    From junit-plugin with MIT License 5 votes vote down vote up
/**
 * Make sure the open junit publisher shows junit history
 * @throws IOException
 * @throws SAXException
 */
@LocalData
@Test
public void testHistoryPageOpenJunit() throws IOException, SAXException {
    Project proj = (Project)rule.jenkins.getItem(TEST_PROJECT_WITH_HISTORY);
    assertNotNull("We should have a project named " + TEST_PROJECT_WITH_HISTORY, proj);

    // Validate that there are test results where I expect them to be:
    WebClient wc = rule.createWebClient();

    HtmlPage historyPage = wc.getPage(proj.getBuildByNumber(7),"/testReport/history/");
    rule.assertGoodStatus(historyPage);
    rule.assertXPath(historyPage, "//img[@id='graph']");
    rule.assertXPath(historyPage, "//table[@id='testresult']");
    DomElement wholeTable = historyPage.getElementById("testresult");
    assertNotNull("table with id 'testresult' exists", wholeTable);
    assertTrue("wholeTable is a table", wholeTable instanceof HtmlTable);
    HtmlTable table = (HtmlTable) wholeTable;

    // We really want to call table.getRowCount(), but
    // it returns 1, not the real answer,
    // because this table has *two* tbody elements,
    // and getRowCount() only seems to count the *first* tbody.
    // Maybe HtmlUnit can't handle the two tbody's. In any case,
    // the tableText.contains tests do a (ahem) passable job
    // of detecting whether the history results are present.

    String tableText = table.getTextContent();
    assertTrue("Table text is missing the project name",
            tableText.contains(TEST_PROJECT_WITH_HISTORY));
    assertTrue("Table text is missing the build number",
            tableText.contains("7"));
    assertTrue("Table text is missing the test duration",
            tableText.contains("4 ms"));
}
 
Example #25
Source File: AggregatedTestResultPublisherTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@LocalData
@Test
public void testResultsAndAggregatedTestResults() throws Exception {
    createUpstreamProjectWithTests();
    createDownstreamProjectWithTests();

    buildAndSetupPageObjects();

    projectPage.getLatestTestReportLink()
            .assertHasLatestTestResultText()
            .assertHasTests()
            .follow();
    projectPage.getLatestAggregatedTestReportLink()
            .assertHasLatestAggregatedTestResultText()
            .assertHasTests()
            .follow();

    buildPage.getTestReportLink()
            .assertHasTestResultText()
            .assertHasTests()
            .follow();
    buildPage.getAggregatedTestReportLink()
            .assertHasAggregatedTestResultText()
            .assertHasTests()
            .follow()
            .hasLinkToTestResultOfBuild(TEST_PROJECT_NAME, 1);
}
 
Example #26
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
public void should_find_project_for_a_url() {
    String testUrl = "https://localhost/test_group/test_job";
    Iterable<DynamicProject> projects = repo.getJobsFor(testUrl);
    assertTrue("Unable to find any projects with test url", projects.iterator().hasNext()); // there is at least one item
    for (DynamicProject project : projects) {
        assertEquals(testUrl, project.getGithubRepoUrl());
    }
}
 
Example #27
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
public void should_delete_a_project() {
    assertEquals(1L, repo.getDatastore().createQuery(DynamicProject.class).countAll());
    DynamicProject project = spy(repo.getProjectById(new ObjectId("5451e5ee30047b534b7bd50b")));
    OrganizationContainer parent = new OrganizationContainer(Jenkins.getInstance(), "groupon");
    doReturn(parent).when(project).getParent();
    repo.delete(project);
    assertEquals(0L, repo.getDatastore().createQuery(DynamicProject.class).countAll());
}
 
Example #28
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
public void should_find_its_children() {
    ObjectId parentId = new ObjectId("54c6a3cd1c265eb3a07d58b4");
    DynamicProject parent = repo.getProjectById(parentId);
    List<DynamicSubProject> children = Lists.newArrayList(repo.getChildren(parent));
    assertEquals(3, children.size()); // database has three sub-builds
    for (DynamicSubProject subProject : children) {
        assertEquals(parentId, subProject.getParent().getId());
    }
}
 
Example #29
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
public void should_find_a_child() {
    ObjectId parentId = new ObjectId("54c6a3cd1c265eb3a07d58b4");
    String name = "script=integration";
    DynamicProject parent = repo.getProjectById(parentId);
    DynamicSubProject child = repo.getChild(parent, name);
    assertNotNull(child);
    assertEquals(name, child.getName());
    assertEquals(parentId, child.getParent().getId());
}
 
Example #30
Source File: DynamicProjectRepositoryTest.java    From DotCi with MIT License 5 votes vote down vote up
@Test
@LocalData
public void should_save_or_update_a_project() throws Exception {
    ObjectId id = new ObjectId("5451e5ee30047b534b7bd50b");
    DynamicProject project = repo.getProjectById(id);
    assertEquals("test_job", project.getDisplayName());
    project.setDisplayName("someothername"); // saves internally
    DynamicProject savedProject = repo.getProjectById(id);
    assertEquals("someothername", savedProject.getDisplayName());
}