Commit 9511d42a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

columns get parameter documented

parent 676746b7
......@@ -68,7 +68,7 @@ public class UserRestImpl extends BaseRestImpl {
return prepareUse(user, columnSet, ldapAvailable);
}
private Set<String> createUserColumnSet(String columns) {
public Set<String> createUserColumnSet(String columns) {
Set<String> columnsSet = new LinkedHashSet<>();
if (columns.equals("")) {
columnsSet.add("id");
......
......@@ -9,6 +9,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
......@@ -22,6 +23,7 @@ import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.restdocs.payload.*;
import org.springframework.restdocs.request.ParameterDescriptor;
import org.springframework.restdocs.request.RequestParametersSnippet;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
......@@ -31,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.gson.*;
import lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator;
import lcsb.mapviewer.api.users.UserRestImpl;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamType;
......@@ -79,6 +82,9 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
@Autowired
private ProjectSnippets projectSnippets;
@Autowired
private UserRestImpl userRestImpl;
@Before
public void setup() {
user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD);
......@@ -251,6 +257,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
String response = mockMvc.perform(request)
.andDo(document("user/get_user",
pathParameters(parameterWithName("login").description("user login")),
userColumListRequestParam(),
responseFields(getUserResponseFields())))
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
......@@ -261,6 +268,15 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
assertEquals(0, privileges.size());
}
private RequestParametersSnippet userColumListRequestParam() {
List<String> columns = new ArrayList<>(userRestImpl.createUserColumnSet(""));
Collections.sort(columns);
return requestParameters(parameterWithName("columns")
.description("comma separated list of columns to be returned (accepted values: "
+ StringUtils.join(columns, ",") + ")")
.optional());
}
@Test
public void testUsersShouldBeFetchedInAlphabeticOrder() throws Exception {
for (int i = 10; i > 0; i--) {
......@@ -700,10 +716,10 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
mockMvc.perform(grantRequest)
.andDo(document("user/list_users",
responseFields(
fieldWithPath("[]")
.description("list of available input formats")
.type("Array")).andWithPrefix("[].", getUserResponseFields())))
userColumListRequestParam(),
responseFields(fieldWithPath("[]")
.description("list of available input formats")
.type("Array")).andWithPrefix("[].", getUserResponseFields())))
.andExpect(status().is2xxSuccessful());
}
......@@ -711,45 +727,59 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
return Arrays.asList(
fieldWithPath("login")
.description("user login")
.optional()
.type("String"),
fieldWithPath("connectedToLdap")
.description("is user account connected to ldap")
.optional()
.type("Boolean"),
fieldWithPath("ldapAccountAvailable")
.description("does is account exist in ldap")
.optional()
.type("Boolean"),
fieldWithPath("email")
.description("email address")
.optional()
.type("String"),
fieldWithPath("id")
.description("user unique id")
.optional()
.type("Number"),
fieldWithPath("maxColor")
.description("color used for drawing data overlays with max value")
.optional()
.type("Color"),
fieldWithPath("minColor")
.description("color used for drawing data overlays with min value")
.optional()
.type("Color"),
fieldWithPath("neutralColor")
.description("color used for drawing data overlays with 0 value")
.optional()
.type("Color"),
fieldWithPath("simpleColor")
.description("color used for drawing data overlays without value")
.optional()
.type("Color"),
fieldWithPath("name")
.description("first name")
.optional()
.type("String"),
fieldWithPath("surname")
.description("last name")
.optional()
.type("String"),
fieldWithPath("removed")
.description("is the account removed")
.optional()
.type("Boolean"),
fieldWithPath("termsOfUseConsent")
.description("did user agree to terms of use")
.optional()
.type("Boolean"),
fieldWithPath("privileges")
.description("list of user privileges")
.optional()
.type("Array"),
fieldWithPath("privileges[].objectId")
.description("object id to which project has privilege")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment