Search in sources :

Example 21 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListDaoTest method testDeleteProteinListItems2.

@Test
public void testDeleteProteinListItems2() {
    Set<String> accs = new HashSet<String>();
    accs.add("pim");
    accs.add("pam");
    accs.add("poum");
    int count = proteinListDao.deleteProteinListItems(156, accs);
    UserProteinList list = proteinListDao.getUserProteinListById(156);
    assertEquals(0, count);
    assertExpectedProteinList(list, 156, "mylist", "my proteins", username, 23, 3, Sets.newHashSet("NX_Q14249", "NX_Q8N5Z0", "NX_P05165"), "ZZZZZU8V");
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) HashSet(java.util.HashSet) UserResourceBaseTest(org.nextprot.api.user.dao.test.base.UserResourceBaseTest) Test(org.junit.Test)

Example 22 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListDaoTest method testCreateUserProteinListAccessions2.

@Test
public void testCreateUserProteinListAccessions2() {
    Set<String> set = new HashSet<String>();
    for (int i = 0; i < 1000; i++) {
        set.add(String.valueOf(i));
    }
    proteinListDao.createUserProteinListItems(156, set);
    UserProteinList list = proteinListDao.getUserProteinListById(156);
    assertExpectedProteinList(list, 156, "mylist", "my proteins", username, 23, 1003, Sets.union(Sets.newHashSet("NX_Q14249", "NX_Q8N5Z0", "NX_P05165"), set), "ZZZZZU8V");
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) HashSet(java.util.HashSet) UserResourceBaseTest(org.nextprot.api.user.dao.test.base.UserResourceBaseTest) Test(org.junit.Test)

Example 23 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListDaoImpl method getUserProteinListByName.

@Override
public UserProteinList getUserProteinListByName(String userIdentifier, String listName) throws DataAccessException {
    String sql = sqlDictionary.getSQLQuery("read-user-protein-list-by-username-listname");
    Map<String, String> namedParams = new HashMap<String, String>();
    namedParams.put("user_name", userIdentifier);
    namedParams.put("list_name", listName);
    UserProteinList userProteinList = new NamedParameterJdbcTemplate(dsLocator.getUserDataSource()).queryForObject(sql, namedParams, new ProteinListRowMapper());
    userProteinList.setAccessions(getAccessionsByListId(userProteinList.getId()));
    return userProteinList;
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) UserProteinList(org.nextprot.api.user.domain.UserProteinList)

Example 24 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListDaoImpl method getUserProteinListByPublicId.

@Override
public UserProteinList getUserProteinListByPublicId(String publicId) throws DataAccessException {
    String sql = sqlDictionary.getSQLQuery("read-user-protein-list-by-pubid");
    SqlParameterSource namedParams = new MapSqlParameterSource("public_id", publicId);
    NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dsLocator.getUserDataSource());
    UserProteinList userProteinList = template.queryForObject(sql, namedParams, new ProteinListRowMapper());
    userProteinList.setAccessions(getAccessionsByListId(userProteinList.getId()));
    return userProteinList;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) UserProteinList(org.nextprot.api.user.domain.UserProteinList)

Example 25 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserResourceAuthorizationServiceTest method testCreateUserProteinListService.

@Test
public void testCreateUserProteinListService() {
    UserProteinList proteinList = Mockito.mock(UserProteinList.class);
    dressMockedUserProteinList(proteinList, "bobleponge");
    Mockito.when(userProteinListDao.getUserProteinListById(anyLong())).thenReturn(proteinList);
    userProteinListService.createUserProteinList(proteinList);
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) Test(org.junit.Test)

Aggregations

UserProteinList (org.nextprot.api.user.domain.UserProteinList)51 Test (org.junit.Test)38 UserResourceBaseTest (org.nextprot.api.user.dao.test.base.UserResourceBaseTest)13 UserProteinListServiceTest.createUserProteinList (org.nextprot.api.user.service.UserProteinListServiceTest.createUserProteinList)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 MVCBaseSecurityTest (org.nextprot.api.web.dbunit.base.mvc.MVCBaseSecurityTest)8 HashSet (java.util.HashSet)5 AbstractUnitBaseTest (org.nextprot.api.commons.dbunit.AbstractUnitBaseTest)4 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)3 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)3 ApiMethod (org.jsondoc.core.annotation.ApiMethod)2 NextProtException (org.nextprot.api.commons.exception.NextProtException)2 UserQuery (org.nextprot.api.user.domain.UserQuery)2 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)2 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)2 IOException (java.io.IOException)1 List (java.util.List)1 AutocompleteSearchResult (org.nextprot.api.solr.AutocompleteSearchResult)1 Query (org.nextprot.api.solr.Query)1 SearchResult (org.nextprot.api.solr.SearchResult)1