Search in sources :

Example 11 with Project

use of org.ligoj.app.model.Project in project plugin-vm by ligoj.

the class VmResource method writeCommon.

/**
 * Write <code>subscription;project;projetKey;projectName;node</code>.
 *
 * @param writer
 *            Target output.
 * @param subscription
 *            Related subscription.
 */
private void writeCommon(final Writer writer, final Subscription subscription) throws IOException {
    final Project project = subscription.getProject();
    writer.write('\n');
    writer.write(String.valueOf(subscription.getId()));
    writer.write(';');
    writer.write(String.valueOf(project.getId()));
    writer.write(';');
    writer.write(project.getPkey());
    writer.write(';');
    writer.write(project.getName().replaceAll("\"", "'"));
    writer.write(';');
    writer.write(subscription.getNode().getId());
}
Also used : Project(org.ligoj.app.model.Project)

Example 12 with Project

use of org.ligoj.app.model.Project in project ligoj-api by ligoj.

the class ProjectResourceTest method create.

/**
 * test create
 */
@Test
public void create() {
    final ProjectEditionVo vo = new ProjectEditionVo();
    vo.setName("Name");
    vo.setDescription("Description");
    vo.setPkey("artifact-id");
    vo.setTeamLeader(DEFAULT_USER);
    final int id = resource.create(vo);
    em.clear();
    final Project entity = repository.findOneExpected(id);
    Assertions.assertEquals("Name", entity.getName());
    Assertions.assertEquals("Description", entity.getDescription());
    Assertions.assertEquals("artifact-id", entity.getPkey());
    Assertions.assertEquals(DEFAULT_USER, entity.getTeamLeader());
}
Also used : Project(org.ligoj.app.model.Project) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 13 with Project

use of org.ligoj.app.model.Project in project ligoj-api by ligoj.

the class ProjectResourceTest method findByIdNotVisible.

/**
 * test {@link ProjectResource#findById(int)}
 */
@Test
public void findByIdNotVisible() {
    final Project byName = repository.findByName("gStack");
    initSpringSecurityContext("any");
    Assertions.assertThrows(BusinessException.class, () -> {
        resource.findById(byName.getId());
    });
}
Also used : Project(org.ligoj.app.model.Project) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 14 with Project

use of org.ligoj.app.model.Project in project ligoj-api by ligoj.

the class ProjectResourceTest method findByIdWithSubscription.

/**
 * test {@link ProjectResource#findById(int)}
 */
@Test
public void findByIdWithSubscription() throws IOException {
    final Project byName = repository.findByName("gStack");
    persistEntities("csv", new Class[] { Event.class }, StandardCharsets.UTF_8.name());
    initSpringSecurityContext("alongchu");
    final ProjectVo project = resource.findById(byName.getId());
    // Check subscription
    Assertions.assertTrue(project.getSubscriptions().size() >= 6);
    for (final SubscriptionVo subscription : project.getSubscriptions()) {
        if (subscription.getStatus() != null) {
            return;
        }
    }
    Assertions.fail("Subscriptions status was expected.");
}
Also used : Project(org.ligoj.app.model.Project) SubscriptionVo(org.ligoj.app.resource.subscription.SubscriptionVo) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 15 with Project

use of org.ligoj.app.model.Project in project ligoj-api by ligoj.

the class ProjectResourceTest method update.

/**
 * test update
 */
@Test
public void update() {
    create();
    final Project project = repository.findByName("Name");
    final ProjectEditionVo vo = new ProjectEditionVo();
    vo.setId(project.getId());
    vo.setName("Name");
    vo.setDescription("D<small>e</small>s<a href=\"#/\">cription</a>");
    vo.setPkey("artifact-id");
    vo.setTeamLeader(DEFAULT_USER);
    resource.update(vo);
    em.clear();
    final Project projFromDB = repository.findOne(project.getId());
    Assertions.assertEquals("Name", projFromDB.getName());
    Assertions.assertEquals("D<small>e</small>s<a href=\"#/\">cription</a>", projFromDB.getDescription());
    Assertions.assertEquals("artifact-id", projFromDB.getPkey());
    Assertions.assertEquals(DEFAULT_USER, projFromDB.getTeamLeader());
}
Also used : Project(org.ligoj.app.model.Project) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Aggregations

Project (org.ligoj.app.model.Project)21 Test (org.junit.jupiter.api.Test)12 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)9 Subscription (org.ligoj.app.model.Subscription)6 SubscriptionVo (org.ligoj.app.resource.subscription.SubscriptionVo)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Node (org.ligoj.app.model.Node)2 Parameter (org.ligoj.app.model.Parameter)2 ParameterValue (org.ligoj.app.model.ParameterValue)2 EventVo (org.ligoj.app.resource.node.EventVo)2 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 DELETE (javax.ws.rs.DELETE)1