Search in sources :

Example 6 with RemoteAPI

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

the class RemoteServiceImplTest method testGetServiceStatus.

@Test
public void testGetServiceStatus() {
    RemoteAPI remoteAPI = new RemoteAPI();
    service.getServiceStatus(remoteAPI);
    verify(repository).getServiceStatus(remoteAPI);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) Test(org.junit.Test)

Example 7 with RemoteAPI

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

the class SampleRemoteServiceImplTest method testGetSamplesForProject.

@Test
public void testGetSamplesForProject() {
    String samplesHref = "http://somewhere/projects/5/samples";
    Project project = new Project();
    project.add(new Link(samplesHref, SampleRemoteServiceImpl.PROJECT_SAMPLES_REL));
    RemoteAPI api = new RemoteAPI();
    project.setRemoteStatus(new RemoteStatus("http://nowhere", api));
    Sample remoteSample = new Sample();
    remoteSample.setRemoteStatus(new RemoteStatus("http://nowhere", api));
    List<Sample> samples = Lists.newArrayList(remoteSample);
    when(sampleRemoteRepository.list(samplesHref, api)).thenReturn(samples);
    List<Sample> samplesForProject = sampleRemoteService.getSamplesForProject(project);
    verify(sampleRemoteRepository).list(samplesHref, api);
    assertEquals(samples, samplesForProject);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) Link(org.springframework.hateoas.Link) Test(org.junit.Test)

Example 8 with RemoteAPI

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

the class SingleEndSequenceFileRemoteServiceImplTest method testGetSequenceFilesForSample.

@Test
public void testGetSequenceFilesForSample() {
    String seqFilesHref = "http://somewhere/projects/1/samples/2/sequencefiles";
    RemoteAPI api = new RemoteAPI();
    Sample sample = new Sample();
    sample.add(new Link(seqFilesHref, SingleEndSequenceFileRemoteServiceImpl.SAMPLE_SEQENCE_FILE_UNPAIRED_REL));
    sample.setRemoteStatus(new RemoteStatus("http://nowhere", api));
    List<SingleEndSequenceFile> filesList = Lists.newArrayList(new SingleEndSequenceFile(new SequenceFile()));
    when(apiRepo.getRemoteAPIForUrl(seqFilesHref)).thenReturn(api);
    when(repository.list(seqFilesHref, api)).thenReturn(filesList);
    List<SingleEndSequenceFile> sequenceFilesForSample = service.getUnpairedFilesForSample(sample);
    assertEquals(filesList, sequenceFilesForSample);
    verify(repository).list(seqFilesHref, api);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) Link(org.springframework.hateoas.Link) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 9 with RemoteAPI

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

the class OAuthTokenRestTemplateIT method testRequestWithExpiredToken.

@Test(expected = IridaOAuthException.class)
public void testRequestWithExpiredToken() throws URISyntaxException {
    RemoteAPI remoteAPI = apiService.read(2L);
    URI serviceURI = new URI(remoteAPI.getServiceURI());
    OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
    restTemplate.getForEntity(serviceURI, String.class);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) URI(java.net.URI) Test(org.junit.Test)

Example 10 with RemoteAPI

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

the class OAuthTokenRestTemplateTest method setUp.

@Before
public void setUp() throws URISyntaxException {
    tokenService = mock(RemoteAPITokenService.class);
    serviceURI = new URI("http://uri");
    remoteAPI = new RemoteAPI("service name", serviceURI.toString(), "a service", "clientId", "clientSecret");
    restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) URI(java.net.URI) RemoteAPITokenService(ca.corefacility.bioinformatics.irida.service.RemoteAPITokenService) OAuthTokenRestTemplate(ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate) Before(org.junit.Before)

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