Search in sources :

Example 1 with PropEntityProjectFeature

use of jetbrains.buildServer.server.rest.model.project.PropEntityProjectFeature in project teamcity-rest by JetBrains.

the class ProjectFinderTest method testProjectBean.

@Test
public void testProjectBean() throws Exception {
    final SProject project10 = createProject("p1", "project 1");
    final SProject project20 = createProject("p2", "project 2");
    final SProject project10_10 = project10.createProject("p10_10", "p1_child1");
    final SProject project10_20 = project10.createProject("p10_20", "xxx");
    final SProject project10_10_10 = project10_10.createProject("p10_10_10", "xxx");
    final SProject project30 = createProject(project10.getProjectId(), "p3");
    Project project = new Project(project10, new Fields("projects($long)"), getBeanContext(myServer));
    assertNotNull(project.projects.projects);
    checkOrderedCollection(CollectionsUtil.convertCollection(project.projects.projects, new Converter<String, Project>() {

        public String createFrom(@NotNull final Project source) {
            return source.id;
        }
    }), project10_10.getExternalId(), project10_20.getExternalId());
    project = new Project(project10, new Fields("projects($long,$locator(name:xxx))"), getBeanContext(myServer));
    assertNotNull(project.projects.projects);
    checkOrderedCollection(CollectionsUtil.convertCollection(project.projects.projects, new Converter<String, Project>() {

        public String createFrom(@NotNull final Project source) {
            return source.id;
        }
    }), project10_20.getExternalId());
    project = new Project(project10, new Fields("projects($long,$locator(project:$any,affectedProject:(" + project10.getExternalId() + ")))"), getBeanContext(myServer));
    assertNotNull(project.projects.projects);
    checkOrderedCollection(CollectionsUtil.convertCollection(project.projects.projects, new Converter<String, Project>() {

        public String createFrom(@NotNull final Project source) {
            return source.id;
        }
    }), project10_10.getExternalId(), project10_20.getExternalId(), project10_10_10.getExternalId());
    ProjectFeatureDescriptorFactory featureDescriptorFactory = myFixture.findSingletonService(ProjectFeatureDescriptorFactory.class);
    assert featureDescriptorFactory != null;
    project10.addFeature(featureDescriptorFactory.createProjectFeature("uniqueId10", "type10", asMap("a", "b", "c", "d"), project10.getProjectId()));
    project10_10.addFeature(featureDescriptorFactory.createProjectFeature("uniqueId20", "type20", asMap("a", "b", "c", "d"), project10_10.getProjectId()));
    project = new Project(project10_10, new Fields("$long"), getBeanContext(myServer));
    assertEquals(project.id, project10_10.getExternalId());
    assertNotNull(project.projectFeatures);
    assertEquals(Integer.valueOf(1), project.projectFeatures.count);
    List<PropEntityProjectFeature> propEntities = project.projectFeatures.propEntities;
    assertEquals(1, propEntities.size());
    PropEntityProjectFeature feature = propEntities.get(0);
    assertEquals("uniqueId20", feature.id);
    assertEquals("type20", feature.type);
    assertEquals(Integer.valueOf(2), feature.properties.count);
    assertEquals("a", feature.properties.properties.get(0).name);
    assertEquals("b", feature.properties.properties.get(0).value);
    assertEquals("c", feature.properties.properties.get(1).name);
    assertEquals("d", feature.properties.properties.get(1).value);
}
Also used : ProjectFeatureDescriptorFactory(jetbrains.buildServer.serverSide.impl.ProjectFeatureDescriptorFactory) Project(jetbrains.buildServer.server.rest.model.project.Project) SProject(jetbrains.buildServer.serverSide.SProject) Fields(jetbrains.buildServer.server.rest.model.Fields) PropEntityProjectFeature(jetbrains.buildServer.server.rest.model.project.PropEntityProjectFeature) Converter(jetbrains.buildServer.util.Converter) SProject(jetbrains.buildServer.serverSide.SProject) NotNull(org.jetbrains.annotations.NotNull) Test(org.testng.annotations.Test)

Aggregations

Fields (jetbrains.buildServer.server.rest.model.Fields)1 Project (jetbrains.buildServer.server.rest.model.project.Project)1 PropEntityProjectFeature (jetbrains.buildServer.server.rest.model.project.PropEntityProjectFeature)1 SProject (jetbrains.buildServer.serverSide.SProject)1 ProjectFeatureDescriptorFactory (jetbrains.buildServer.serverSide.impl.ProjectFeatureDescriptorFactory)1 Converter (jetbrains.buildServer.util.Converter)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.testng.annotations.Test)1