Search in sources :

Example 1 with IArtifactRequest

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRequest in project tycho by eclipse.

the class LocalArtifactRepositoryTest method testGetArtifactsErrorRequest.

@Test
public void testGetArtifactsErrorRequest() {
    LocalArtifactRepository repo = new LocalArtifactRepository(localRepoIndices);
    IArtifactRequest errorRequest = new IArtifactRequest() {

        @Override
        public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) {
        }

        @Override
        public IStatus getResult() {
            return new Status(IStatus.ERROR, "test-bundle", "Error");
        }

        @Override
        public IArtifactKey getArtifactKey() {
            return null;
        }
    };
    IStatus status = repo.getArtifacts(new IArtifactRequest[] { errorRequest }, new NullProgressMonitor());
    assertThat(status, not(okStatus()));
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) StatusMatchers.okStatus(org.eclipse.tycho.test.util.StatusMatchers.okStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IArtifactRequest(org.eclipse.equinox.p2.repository.artifact.IArtifactRequest) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Example 2 with IArtifactRequest

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRequest in project tycho by eclipse.

the class RepositoryArtifactProviderTest method createArtifactRepositoryMock.

private static IArtifactRepository createArtifactRepositoryMock() {
    /*
         * Create an IArtifactRepository mock instance with the default implementation of
         * org.eclipse.equinox.p2.repository.artifact.IArtifactRepository.getArtifacts(
         * IArtifactRequest[], IProgressMonitor)
         */
    IArtifactRepository partialMock = mock(AbstractArtifactRepository2.class);
    when(partialMock.getArtifacts(any(IArtifactRequest[].class), any(IProgressMonitor.class))).thenCallRealMethod();
    return partialMock;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)

Example 3 with IArtifactRequest

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRequest in project tycho by eclipse.

the class AbstractArtifactRepository2 method getArtifacts.

// add default implementations missing in AbstractArtifactRepository
@Override
public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
    SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
    try {
        MultiStatus result = new MultiStatus(BUNDLE_ID, 0, "Error while getting requested artifacts", null);
        for (IArtifactRequest request : requests) {
            request.perform(this, subMonitor.newChild(1));
            result.add(request.getResult());
        }
        if (!result.isOK()) {
            return result;
        } else {
            return Status.OK_STATUS;
        }
    } finally {
        monitor.done();
    }
}
Also used : IArtifactRequest(org.eclipse.equinox.p2.repository.artifact.IArtifactRequest) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)2 IArtifactRequest (org.eclipse.equinox.p2.repository.artifact.IArtifactRequest)2 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 StatusMatchers.okStatus (org.eclipse.tycho.test.util.StatusMatchers.okStatus)1 Test (org.junit.Test)1