use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListServiceTest method testCreateProteinList.
@Test
public void testCreateProteinList() {
final UserProteinList proteinList = createUserProteinList("awesome", Sets.newHashSet("NX_P123"));
dressMockedUserProteinListDao(proteinList, 10);
UserProteinList created = proteinListService.createUserProteinList(proteinList);
assertEquals(10, created.getId());
assertEquals("awesome", created.getName());
assertEquals(Sets.newHashSet("NX_P123"), created.getAccessionNumbers());
Mockito.verify(stringGenerator, times(1)).generateString();
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListServiceTest method createUserProteinList.
/*@Test
public void testAddAccessions() {
Set<String> s1 = new HashSet<String>();
s1.add("NX_P123");
s1.add("NX_P456");
UserProteinList l1 = proteinListService.createUserProteinList(mockSpongeBobProteinList("cool1", s1));
Set<String> accs = new HashSet<String>();
s1.add("NX_P124");
this.proteinListService.updateUserProteinListMetadata(l1.getId(), accs);
}
@Test
public void testRemoveAccessions() {
Set<String> s1 = new HashSet<String>();
s1.add("NX_P123");
s1.add("NX_P456");
UserProteinList l1 = this.proteinListService.createUserProteinList(mockSpongeBobProteinList("cool1", s1));
assertEquals("cool1", l1.getName());
assertEquals(2, l1.getAccessionNumbers().size());
Set<String> remAcc = new HashSet<String>();
remAcc.add("NX_P123");
this.proteinListService.removeAccessionNumbers(l1.getId(), remAcc);
l1 = this.proteinListService.getUserProteinListById(l1.getId());
assertEquals("cool1", l1.getName());
assertEquals(1, l1.getAccessionNumbers().size());
}*/
public static UserProteinList createUserProteinList(String name, Set<String> accessions) {
UserProteinList ul = new UserProteinList();
ul.setName(name);
ul.setAccessions(accessions);
return ul;
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListServiceTest method testGeneratePubIdInCreateProteinList.
@Test
public void testGeneratePubIdInCreateProteinList() {
UserProteinList proteinList = createUserProteinList("awesome", Sets.newHashSet("NX_P123"));
Mockito.when(dao.createUserProteinList(proteinList)).thenThrow(new DuplicateKeyException("PreparedStatementCallback; SQL [INSERT INTO np_users.user_protein_lists (list_name, description, owner_id, public_id)\n" + "VALUES (?, ?, ?, ?);]; ERROR: duplicate key value violates unique constraint \"user_protein_lists_pubid_udx\"\n" + " Detail: Key (public_id)=(00000001) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint \"user_protein_lists_pubid_udx\"\n" + " Detail: Key (public_id)=(00000001) already exists.")).thenThrow(new DuplicateKeyException("PreparedStatementCallback; SQL [INSERT INTO np_users.user_protein_lists (list_name, description, owner_id, public_id)\n" + "VALUES (?, ?, ?, ?);]; ERROR: duplicate key value violates unique constraint \"user_protein_lists_pubid_udx\"\n" + " Detail: Key (public_id)=(00000001) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint \"user_protein_lists_pubid_udx\"\n" + " Detail: Key (public_id)=(00000001) already exists.")).thenReturn(1L);
proteinListService.createUserProteinList(proteinList);
Mockito.verify(stringGenerator, times(3)).generateString();
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListUtilsTest method testCombineOr.
@Test
public void testCombineOr() {
UserProteinList l1 = createUserProteinList("cool1", Sets.newHashSet("NX_P123", "NX_P456"));
UserProteinList l2 = createUserProteinList("cool2", Sets.newHashSet("NX_P123", "NX_P321"));
UserProteinList l3 = UserProteinListUtils.combine(l1, l2, UserProteinListService.Operator.OR, "bobleponge", "coolio", null);
assertEquals("coolio", l3.getName());
assertEquals(3, l3.getAccessionNumbers().size());
assertEquals("bobleponge", l3.getOwner());
assertEquals(Sets.newHashSet("NX_P123", "NX_P456", "NX_P321"), l3.getAccessionNumbers());
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListUtilsTest method testCombineAnd.
@Test
public void testCombineAnd() {
UserProteinList l1 = createUserProteinList("cool1", Sets.newHashSet("NX_P123", "NX_P456"));
UserProteinList l2 = createUserProteinList("cool2", Sets.newHashSet("NX_P123", "NX_P321"));
UserProteinList l3 = UserProteinListUtils.combine(l1, l2, UserProteinListService.Operator.AND, "bobleponge", "homie", null);
assertEquals("homie", l3.getName());
assertEquals(1, l3.getAccessionNumbers().size());
assertEquals("bobleponge", l3.getOwner());
assertEquals("NX_P123", l3.getAccessionNumbers().iterator().next());
}
Aggregations