use of org.nextprot.api.user.domain.UserQuery in project nextprot-api by calipho-sib.
the class UserQueryDaoTest method testDeleteUserQueryTags.
@Test
public void testDeleteUserQueryTags() {
Set<String> accs = new HashSet<String>();
accs.add("public");
int count = userQueryDao.deleteUserQueryTags(16, accs);
UserQuery query = userQueryDao.getUserQueryById(16);
assertEquals(1, count);
assertExpectedUserQuery(query, 16, "spongebob", "myquery2", "my second query", true, "another sparql query", "ZZZZZU8V", Sets.<String>newHashSet());
}
use of org.nextprot.api.user.domain.UserQuery in project nextprot-api by calipho-sib.
the class UserQueryServiceTest method testGeneratePubIdInCreateUserQuery.
@Test
public void testGeneratePubIdInCreateUserQuery() {
UserQuery userQuery = createUserQuery("ma requete", "une simple requete", "yet another sparql query", true);
Mockito.when(dao.createUserQuery(userQuery)).thenThrow(new DuplicateKeyException("ERROR: duplicate key value violates unique constraint \"user_queries_pubid_udx\"\n" + " Detail: Key (public_id)=(00000002) already exists.")).thenThrow(new DuplicateKeyException("ERROR: duplicate key value violates unique constraint \"user_queries_pubid_udx\"\n" + " Detail: Key (public_id)=(00000002) already exists.")).thenReturn(1L);
userQueryService.createUserQuery(userQuery);
Mockito.verify(stringGenerator, times(3)).generateString();
}
use of org.nextprot.api.user.domain.UserQuery in project nextprot-api by calipho-sib.
the class UserResourceAuthorizationServiceTest method testUpdateUserQueryService2.
@Test(expected = NotAuthorizedException.class)
public void testUpdateUserQueryService2() {
UserQuery query = mockUserQuery("bobbylapointe");
Mockito.when(userQueryDao.getUserQueryById(anyLong())).thenReturn(query);
userQueryService.updateUserQuery(query);
}
use of org.nextprot.api.user.domain.UserQuery in project nextprot-api by calipho-sib.
the class UserResourceAuthorizationServiceTest method mockUserQuery.
private static UserQuery mockUserQuery(String owner) {
UserQuery query = Mockito.mock(UserQuery.class);
Mockito.when(query.getOwnerName()).thenReturn(owner);
Mockito.when(query.getOwnerId()).thenReturn(23L);
Mockito.when(query.getSparql()).thenReturn("orkfiejjgijrtwithi");
return query;
}
use of org.nextprot.api.user.domain.UserQuery in project nextprot-api by calipho-sib.
the class SearchController method runQuery.
/**
* Useful to build the cache for sparql queries on a target api server (typically build-api.nextprot.org)
* @param queryId a query public id
* @return either the number of entries returned by the queries (if query is a snorql only, the number returned will be 0) or an error message
*/
@RequestMapping(value = "/sparql/run", method = { RequestMethod.GET })
@ResponseBody
public Map<String, Object> runQuery(@RequestParam(value = "queryId", required = true) String queryId) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("queryId", queryId);
try {
UserQuery uq = userQueryService.getUserQueryByPublicId(queryId);
List<String> entries = sparqlService.findEntries(uq.getSparql(), sparqlEndpoint.getUrl(), uq.getTitle());
result.put("entryCount", entries.size());
} catch (Exception e) {
result.put("error", e.getMessage());
}
return result;
}
Aggregations