Search in sources :

Example 11 with RemoteAPI

use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.

the class RemoteAPIServiceImplIT method testGetApiByURLNoMatch.

@Test
@WithMockUser(username = "tom", roles = "USER")
public void testGetApiByURLNoMatch() {
    String resourceURL = "http://somewhereelse.ca/api/projects/2";
    RemoteAPI apiForUrl = remoteAPIService.getRemoteAPIForUrl(resourceURL);
    assertNull(apiForUrl);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 12 with RemoteAPI

use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.

the class RemoteAPITokenServiceImplIT method testGetTokenNotExists.

@Test(expected = EntityNotFoundException.class)
public void testGetTokenNotExists() {
    RemoteAPI api = apiService.read(2L);
    tokenService.getToken(api);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) Test(org.junit.Test)

Example 13 with RemoteAPI

use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.

the class RemoteAPITokenServiceImplIT method addTokenExisting.

@Test
public void addTokenExisting() {
    RemoteAPI api = apiService.read(1L);
    RemoteAPIToken originalToken = tokenService.getToken(api);
    RemoteAPIToken token = new RemoteAPIToken("111111111", api, new Date());
    tokenService.create(token);
    RemoteAPIToken readToken = tokenService.getToken(api);
    assertNotEquals(token, originalToken);
    assertEquals(token, readToken);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) RemoteAPIToken(ca.corefacility.bioinformatics.irida.model.RemoteAPIToken) Date(java.util.Date) Test(org.junit.Test)

Example 14 with RemoteAPI

use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.

the class RemoteAPITokenServiceImplIT method testAddToken.

@Test
public void testAddToken() {
    RemoteAPI api = apiService.read(2L);
    RemoteAPIToken token = new RemoteAPIToken("111111111", api, new Date());
    tokenService.create(token);
    RemoteAPIToken readToken = tokenService.getToken(api);
    assertEquals(token, readToken);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) RemoteAPIToken(ca.corefacility.bioinformatics.irida.model.RemoteAPIToken) Date(java.util.Date) Test(org.junit.Test)

Example 15 with RemoteAPI

use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.

the class RemoteAPIControllerTest method testCheckApiStatusActive.

@Test
public void testCheckApiStatusActive() {
    Long apiId = 1L;
    RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
    when(remoteAPIService.read(apiId)).thenReturn(client);
    when(projectRemoteService.getServiceStatus(client)).thenReturn(true);
    String checkApiStatus = remoteAPIController.checkApiStatus(apiId);
    assertEquals(RemoteAPIController.VALID_OAUTH_CONNECTION, checkApiStatus);
    verify(remoteAPIService).read(apiId);
    verify(projectRemoteService).getServiceStatus(client);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) Test(org.junit.Test)

Aggregations

RemoteAPI (ca.corefacility.bioinformatics.irida.model.RemoteAPI)44 Test (org.junit.Test)30 RemoteAPIToken (ca.corefacility.bioinformatics.irida.model.RemoteAPIToken)6 ExtendedModelMap (org.springframework.ui.ExtendedModelMap)6 URI (java.net.URI)5 Date (java.util.Date)5 Link (org.springframework.hateoas.Link)5 IridaOAuthException (ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException)4 Project (ca.corefacility.bioinformatics.irida.model.project.Project)4 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)3 RemoteStatus (ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus)3 Before (org.junit.Before)3 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)2 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)2 User (ca.corefacility.bioinformatics.irida.model.user.User)2 OAuthTokenRestTemplate (ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 MockRestServiceServer (org.springframework.test.web.client.MockRestServiceServer)2