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());
}
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());
}
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());
});
}
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.");
}
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());
}
Aggregations