use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class RemoteAPIControllerTest method testPostCreateRemoteAPIError.
@Test
public void testPostCreateRemoteAPIError() {
RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
client.setId(1L);
ExtendedModelMap model = new ExtendedModelMap();
Locale locale = LocaleContextHolder.getLocale();
DataIntegrityViolationException ex = new DataIntegrityViolationException("Error: " + RemoteAPI.SERVICE_URI_CONSTRAINT_NAME);
when(remoteAPIService.create(client)).thenThrow(ex);
String postCreateClient = remoteAPIController.postCreateRemoteAPI(client, model, locale);
assertEquals(RemoteAPIController.ADD_API_PAGE, postCreateClient);
assertTrue(model.containsAttribute("errors"));
@SuppressWarnings("unchecked") Map<String, String> errors = (Map<String, String>) model.get("errors");
assertTrue(errors.containsKey("serviceURI"));
verify(remoteAPIService).create(client);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class RemoteAPIControllerTest method testPostCreateRemoteAPI.
@Test
public void testPostCreateRemoteAPI() {
RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
client.setId(1L);
ExtendedModelMap model = new ExtendedModelMap();
when(remoteAPIService.create(client)).thenReturn(client);
String postCreateClient = remoteAPIController.postCreateRemoteAPI(client, model, locale);
assertEquals("redirect:/remote_api/1", postCreateClient);
verify(remoteAPIService).create(client);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class RemoteAPIServiceImplIT method testGetApiByURL.
@Test
@WithMockUser(username = "tom", roles = "USER")
public void testGetApiByURL() {
String resourceURL = "http://irida.ca/api/projects/2";
RemoteAPI apiForUrl = remoteAPIService.getRemoteAPIForUrl(resourceURL);
assertNotNull(apiForUrl);
assertTrue(resourceURL.contains(apiForUrl.getServiceURI()));
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class RemoteAPITokenServiceImplIT method testDeleteToken.
@Test(expected = EntityNotFoundException.class)
public void testDeleteToken() {
RemoteAPI api = null;
try {
api = apiService.read(1L);
tokenService.delete(api);
} catch (EntityNotFoundException ex) {
fail("Token should be able to be deleted");
}
tokenService.getToken(api);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class RemoteAPITokenServiceImplIT method testGetToken.
@Test
public void testGetToken() {
RemoteAPI api = apiService.read(1L);
RemoteAPIToken token = tokenService.getToken(api);
assertNotNull(token);
assertEquals("123456789", token.getTokenString());
}
Aggregations