Skip to content
Snippets Groups Projects
Commit cb52f34d authored by anttil's avatar anttil
Browse files

BIS-534 / SP-899: Project DTO is missing description

SVN: 29813
parent d21f5d4a
No related branches found
No related tags found
No related merge requests found
......@@ -290,7 +290,7 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio
for (ProjectPE project : projects)
{
fullSpace.add(new Project(project.getId(), project.getPermId(), fullSpace.getCode(),
project.getCode()));
project.getCode(), project.getDescription()));
}
}
......
......@@ -145,7 +145,7 @@ public class Translator
{
EntityRegistrationDetails registrationDetails = translateRegistrationDetails(project);
return new Project(project.getId(), project.getPermId(), project.getSpace().getCode(),
project.getCode(), registrationDetails);
project.getCode(), project.getDescription(), registrationDetails);
}
public static List<Sample> translateSamples(
......
......@@ -26,8 +26,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil;
import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentifierHolder;
/**
* Immutable value object representing a project. A project is specified by its code and the code of
* the space to which it belongs.
* Immutable value object representing a project. A project is specified by its code and the code of the space to which it belongs.
*
* @author Franz-Josef Elmer
*/
......@@ -45,24 +44,24 @@ public final class Project implements Serializable, IIdentifierHolder
private String code;
private String description;
private EntityRegistrationDetails registrationDetails;
/**
* Creates a new instance for the specified tech id, perm id, space code and project code.
*
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or
* an empty string.
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or an empty string.
*/
public Project(Long id, String permId, String spaceCode, String code)
public Project(Long id, String permId, String spaceCode, String code, String description)
{
this(id, permId, spaceCode, code, null);
this(id, permId, spaceCode, code, description, null);
}
/**
* Creates a new instance for the specified space code and project code.
*
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or
* an empty string.
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or an empty string.
*/
public Project(String spaceCode, String code)
{
......@@ -72,8 +71,7 @@ public final class Project implements Serializable, IIdentifierHolder
/**
* Creates a new instance for the specified tech id, perm id, space code and project code.
*
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or
* an empty string.
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or an empty string.
*/
public Project(String spaceCode, String code, EntityRegistrationDetails registrationDetails)
{
......@@ -84,10 +82,9 @@ public final class Project implements Serializable, IIdentifierHolder
/**
* Creates a new instance for the specified space code and project code.
*
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or
* an empty string.
* @throws IllegalArgumentException if either the code or the space code is <code>null</code> or an empty string.
*/
public Project(Long id, String permId, String spaceCode, String code,
public Project(Long id, String permId, String spaceCode, String code, String description,
EntityRegistrationDetails registrationDetails)
{
if (id == null || id == 0)
......@@ -101,6 +98,7 @@ public final class Project implements Serializable, IIdentifierHolder
}
this.permId = permId;
checkAndSetCodes(spaceCode, code);
this.description = description;
this.registrationDetails = registrationDetails;
}
......@@ -156,6 +154,14 @@ public final class Project implements Serializable, IIdentifierHolder
return code;
}
/**
* Returns the project description.
*/
public String getDescription()
{
return description;
}
@Override
@JsonIgnore
public String getIdentifier()
......@@ -317,6 +323,11 @@ public final class Project implements Serializable, IIdentifierHolder
this.code = code;
}
private void setDescription(String description)
{
this.description = description;
}
private void setRegistrationDetails(EntityRegistrationDetails registrationDetails)
{
this.registrationDetails = registrationDetails;
......
......@@ -109,7 +109,7 @@ class ProteomicsDataApiFacade implements IProteomicsDataApiFacade
.getProjects())
{
projects.add(new Project(project.getId(), project.getPermId(), space.getCode(),
project.getCode()));
project.getCode(), project.getDescription()));
}
}
}
......
......@@ -34,24 +34,23 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SpaceWithProjectsAndRoleAssignments;
import ch.systemsx.cisd.openbis.plugin.proteomics.client.api.v1.IProteomicsDataApiFacade;
import ch.systemsx.cisd.openbis.plugin.proteomics.client.api.v1.ProteomicsDataApiFacade;
import ch.systemsx.cisd.openbis.plugin.proteomics.shared.api.v1.IProteomicsDataService;
import ch.systemsx.cisd.openbis.plugin.proteomics.shared.api.v1.dto.DataStoreServerProcessingPluginInfo;
import ch.systemsx.cisd.openbis.plugin.proteomics.shared.api.v1.dto.MsInjectionDataInfo;
/**
*
*
* @author Franz-Josef Elmer
*/
public class ProteomicsDataApiFacadeTest extends AssertJUnit
{
private static final String SESSION_TOKEN = "Session-42";
private Mockery context;
private IProteomicsDataService proteomicsDataService;
private IGeneralInformationService generalInfoService;
private IProteomicsDataApiFacade facade;
@BeforeMethod
......@@ -62,21 +61,21 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit
generalInfoService = context.mock(IGeneralInformationService.class);
facade = new ProteomicsDataApiFacade(proteomicsDataService, generalInfoService, SESSION_TOKEN);
}
@AfterMethod
public void afterMethod()
{
context.assertIsSatisfied();
}
@Test
public void testGetSessionToken()
{
assertEquals(SESSION_TOKEN, facade.getSessionToken());
context.assertIsSatisfied();
}
@Test
public void testLogout()
{
......@@ -86,12 +85,12 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit
one(generalInfoService).logout(SESSION_TOKEN);
}
});
facade.logout();
context.assertIsSatisfied();
}
@Test
public void testListDataStoreServerProcessingPluginInfos()
{
......@@ -104,7 +103,7 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit
will(returnValue(result));
}
});
assertSame(result, facade.listDataStoreServerProcessingPluginInfos());
context.assertIsSatisfied();
}
......@@ -151,7 +150,7 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit
will(returnValue(new HashMap<String, Set<Role>>()));
}
});
try
{
facade.listProjects("user1");
......@@ -160,47 +159,47 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit
{
assertEquals("Role set SPACE_USER not known.", ex.getMessage());
}
context.assertIsSatisfied();
}
@Test
public void testListProjects()
{
context.checking(new Expectations()
{
{
one(generalInfoService).listNamedRoleSets(SESSION_TOKEN);
HashMap<String, Set<Role>> sets = new HashMap<String, Set<Role>>();
HashSet<Role> set = new HashSet<Role>();
set.add(new Role("R1", true));
set.add(new Role("R2", false));
sets.put("SPACE_USER", set);
will(returnValue(sets));
one(generalInfoService).listSpacesWithProjectsAndRoleAssignments(SESSION_TOKEN, null);
SpaceWithProjectsAndRoleAssignments a = createSpace("A", "alpha", "beta");
a.add("user1", new Role("R1", true));
a.add("user1", new Role("R3", false));
SpaceWithProjectsAndRoleAssignments b = createSpace("B", "gamma");
b.add("user1", new Role("R2", true));
will(returnValue(Arrays.asList(a, b)));
}
});
{
one(generalInfoService).listNamedRoleSets(SESSION_TOKEN);
HashMap<String, Set<Role>> sets = new HashMap<String, Set<Role>>();
HashSet<Role> set = new HashSet<Role>();
set.add(new Role("R1", true));
set.add(new Role("R2", false));
sets.put("SPACE_USER", set);
will(returnValue(sets));
one(generalInfoService).listSpacesWithProjectsAndRoleAssignments(SESSION_TOKEN, null);
SpaceWithProjectsAndRoleAssignments a = createSpace("A", "alpha", "beta");
a.add("user1", new Role("R1", true));
a.add("user1", new Role("R3", false));
SpaceWithProjectsAndRoleAssignments b = createSpace("B", "gamma");
b.add("user1", new Role("R2", true));
will(returnValue(Arrays.asList(a, b)));
}
});
List<Project> projects = facade.listProjects("user1");
assertEquals("[/A/alpha, /A/beta]", projects.toString());
context.assertIsSatisfied();
}
private SpaceWithProjectsAndRoleAssignments createSpace(String spaceCode, String... projects)
{
SpaceWithProjectsAndRoleAssignments space = new SpaceWithProjectsAndRoleAssignments(spaceCode);
long id = 1;
for (String project : projects)
{
space.add(new Project(id, Long.toString(id), spaceCode, project));
space.add(new Project(id, Long.toString(id), spaceCode, project, null));
++id;
}
return space;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment