Search in sources :

Example 1 with Payload

use of org.sonatype.nexus.repository.view.Payload in project nexus-repository-r by sonatype-nexus-community.

the class PackagesGroupHandlerTest method setupRepository.

// Commented out until GroupHandler.DispactchedRepositories is made public
/*  @Test
  public void okWhenGetPackagesWithSingleResponse() throws Exception {
    Response response = underTest.doGet(context, dispatchedRepositories);
    assertThat(response.getStatus().getCode(), is(equalTo(200)));
  }

  @Test
  public void okWhenGetPackagesWithMultipleResponses() throws Exception {
    members.add(repository2);
    Response response = underTest.doGet(context, dispatchedRepositories);
    assertThat(response.getStatus().getCode(), is(equalTo(200)));
  }

  @Test
  public void notFoundWhenNoResponses() throws Exception {
    members.clear();
    Response response = underTest.doGet(context, dispatchedRepositories);
    assertThat(response.getStatus().getCode(), is(equalTo(404)));
  }*/
private void setupRepository(final Repository repository) throws Exception {
    ViewFacet viewFacet = mock(ViewFacet.class);
    Response response = mock(Response.class);
    Payload payload = mock(Payload.class);
    GroupFacet groupFacet = mock(GroupFacet.class);
    when(groupFacet.members()).thenReturn(members);
    when(repository.facet(GroupFacet.class)).thenReturn(groupFacet);
    when(repository.facet(ViewFacet.class)).thenReturn(viewFacet);
    when(viewFacet.dispatch(any(), any())).thenReturn(response);
    when(response.getPayload()).thenReturn(payload);
    when(payload.openInputStream()).thenReturn(new FileInputStream(packages));
    when(response.getStatus()).thenReturn(new Status(true, 200));
}
Also used : Response(org.sonatype.nexus.repository.view.Response) Status(org.sonatype.nexus.repository.view.Status) GroupFacet(org.sonatype.nexus.repository.group.GroupFacet) ViewFacet(org.sonatype.nexus.repository.view.ViewFacet) Payload(org.sonatype.nexus.repository.view.Payload) FileInputStream(java.io.FileInputStream)

Example 2 with Payload

use of org.sonatype.nexus.repository.view.Payload in project nexus-repository-r by sonatype-nexus-community.

the class PackagesGroupHandlerTest method setupRepository.

// Commented out until GroupHandler.DispactchedRepositories is made public
/*  @Test
  public void okWhenGetPackagesWithSingleResponse() throws Exception {
    Response response = underTest.doGet(context, dispatchedRepositories);
    assertThat(response.getStatus().getCode(), is(equalTo(200)));
  }

  @Test
  public void okWhenGetPackagesWithMultipleResponses() throws Exception {
    members.add(repository2);
    Response response = underTest.doGet(context, dispatchedRepositories);
    assertThat(response.getStatus().getCode(), is(equalTo(200)));
  }

  @Test
  public void notFoundWhenNoResponses() throws Exception {
    members.clear();
    Response response = underTest.doGet(context, dispatchedRepositories);
    assertThat(response.getStatus().getCode(), is(equalTo(404)));
  }*/
private void setupRepository(final Repository repository) throws Exception {
    ViewFacet viewFacet = mock(ViewFacet.class);
    Response response = mock(Response.class);
    Payload payload = mock(Payload.class);
    GroupFacet groupFacet = mock(GroupFacet.class);
    when(groupFacet.members()).thenReturn(members);
    when(repository.facet(GroupFacet.class)).thenReturn(groupFacet);
    when(repository.facet(ViewFacet.class)).thenReturn(viewFacet);
    when(viewFacet.dispatch(any(), any())).thenReturn(response);
    when(response.getPayload()).thenReturn(payload);
    when(payload.openInputStream()).thenReturn(new FileInputStream(packages));
    when(response.getStatus()).thenReturn(new Status(true, 200));
}
Also used : Response(org.sonatype.nexus.repository.view.Response) Status(org.sonatype.nexus.repository.view.Status) GroupFacet(org.sonatype.nexus.repository.group.GroupFacet) ViewFacet(org.sonatype.nexus.repository.view.ViewFacet) Payload(org.sonatype.nexus.repository.view.Payload) FileInputStream(java.io.FileInputStream)

Aggregations

FileInputStream (java.io.FileInputStream)2 GroupFacet (org.sonatype.nexus.repository.group.GroupFacet)2 Payload (org.sonatype.nexus.repository.view.Payload)2 Response (org.sonatype.nexus.repository.view.Response)2 Status (org.sonatype.nexus.repository.view.Status)2 ViewFacet (org.sonatype.nexus.repository.view.ViewFacet)2