Examples of MirrorResourceListResponse


Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

    }
    finally {
      fw.close();
    }

    MirrorResourceListResponse response = mirrorUtils.getPredefinedMirrors(PROXY_REPO_ID);

    Assert.assertEquals(3, response.getData().size());
    Assert.assertEquals(((MirrorResource) response.getData().get(0)).getId(), "id1");
    Assert.assertEquals(((MirrorResource) response.getData().get(0)).getUrl(),
        "http://localhost:8081/somemirror/");
    Assert.assertEquals(((MirrorResource) response.getData().get(1)).getId(), "id2");
    Assert.assertEquals(((MirrorResource) response.getData().get(1)).getUrl(),
        "http://localhost:8086/somemirror2/");
    Assert.assertEquals(((MirrorResource) response.getData().get(2)).getId(), "id3");
    Assert.assertEquals(((MirrorResource) response.getData().get(2)).getUrl(),
        "http://localhost:8086/somemirror3/");
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

  }

  @Test
  public void testGetRemoteMirrorList() throws IOException {
    MirrorMessageUtils mirrorUtils = new MirrorMessageUtils(this.getJsonXStream(), MediaType.APPLICATION_JSON);
    MirrorResourceListResponse response = mirrorUtils.getPredefinedMirrors(this.getTestRepositoryId());

    List<MirrorResource> mirrorResources = response.getData();

    HashMap<String, String> mirrorIdMap = new HashMap<String, String>();

    for (MirrorResource mirrorResource : mirrorResources) {
      mirrorIdMap.put(mirrorResource.getId(), mirrorResource.getUrl());
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

    resource = new MirrorResource();
    resource.setUrl("http://updateMirrorTest2");
    request.addData(resource);

    MirrorResourceListResponse response = this.messageUtil.setMirrors(repositoryId, request);

    request.setData(response.getData());

    resource = new MirrorResource();
    resource.setUrl("http://updateMirrorTest3");
    request.addData(resource);

    (request.getData().iterator().next()).setUrl("http://updateMirrorTest4");

    response = this.messageUtil.setMirrors(repositoryId, request);

    MirrorResource one = response.getData().get(0);
    MirrorResource two = response.getData().get(1);
    MirrorResource three = response.getData().get(2);

    Assert.assertEquals(one.getUrl(), "http://updateMirrorTest4");
    Assert.assertEquals(two.getUrl(), "http://updateMirrorTest2");
    Assert.assertEquals(three.getUrl(), "http://updateMirrorTest3");
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

    resource.setUrl("http://getMirrorTest2");
    request.addData(resource);

    this.messageUtil.setMirrors(repositoryId, request);

    MirrorResourceListResponse response = this.messageUtil.getMirrors(repositoryId);

    MirrorResource one = response.getData().get(0);
    MirrorResource two = response.getData().get(1);

    Assert.assertEquals(one.getUrl(), "http://getMirrorTest1");
    Assert.assertEquals(two.getUrl(), "http://getMirrorTest2");
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

    resource = new MirrorResource();
    resource.setUrl("http://updateMirrorTest3");
    request.addData(resource);

    MirrorResourceListResponse response = messageUtil.setMirrors(repositoryId, request);

    Assert.assertEquals(3, response.getData().size());
    Assert.assertEquals((response.getData().get(0)).getId(), "http://updateMirrorTest1");
    Assert.assertEquals((response.getData().get(0)).getUrl(), "http://updateMirrorTest1");
    Assert.assertEquals((response.getData().get(1)).getId(), "http://updateMirrorTest2");
    Assert.assertEquals((response.getData().get(1)).getUrl(), "http://updateMirrorTest2");
    Assert.assertEquals((response.getData().get(2)).getId(), "http://updateMirrorTest3");
    Assert.assertEquals((response.getData().get(2)).getUrl(), "http://updateMirrorTest3");

    // Now read the metadata
    File metadata =
        new File(AbstractNexusIntegrationTest.nexusWorkDir + "/storage/" + repositoryId
            + "/.meta/repository-metadata.xml");
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

  @Override
  @GET
  public MirrorResourceListResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    MirrorResourceListResponse dto = new MirrorResourceListResponse();

    // Hack to get the object created, so response contains the 'data'
    // element even if no mirrors defined
    dto.getData();

    try {
      Repository repository = getRepositoryRegistry().getRepository(getRepositoryId(request));

      for (Mirror mirror : getMirrors(repository)) {
        dto.addData(nexusToRestModel(mirror));
      }
    }
    catch (NoSuchRepositoryException e) {
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid repository id "
          + getRepositoryId(request), e);
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

  @Override
  @POST
  public MirrorResourceListResponse post(Context context, Request request, Response response, Object payload)
      throws ResourceException
  {
    MirrorResourceListResponse dto = new MirrorResourceListResponse();

    try {
      List<MirrorResource> resources = (List<MirrorResource>) ((MirrorResourceListRequest) payload).getData();

      List<Mirror> mirrors = restToNexusModel(resources);

      Repository repository = getRepositoryRegistry().getRepository(getRepositoryId(request));

      setMirrors(repository, mirrors);

      dto.setData(nexusToRestModel(mirrors));
    }
    catch (NoSuchRepositoryException e) {
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid repository id " + getRepositoryId(request),
          e);
    }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

  }

  @Test
  public void testMirrorResourceListResponse() {
    MirrorResourceListResponse response = new MirrorResourceListResponse();

    MirrorResource data = new MirrorResource();
    data.setId("id");
    data.setUrl("url");

    response.addData(data);

    MirrorResource data2 = new MirrorResource();
    data2.setId("id2");
    data2.setUrl("url2");

    response.addData(data2);

    this.marshalUnmarchalThenCompare(response);
    this.validateXmlHasNoPackageNames(response);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

  @Override
  @GET
  public MirrorResourceListResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    MirrorResourceListResponse dto = new MirrorResourceListResponse();

    String repositoryId = this.getRepositoryId(request);

    // get remote metadata
    RepositoryMetadata metadata = this.getMetadata(repositoryId);

    if (metadata != null) {
      for (RepositoryMirrorMetadata mirror : (List<RepositoryMirrorMetadata>) metadata.getMirrors()) {
        MirrorResource resource = new MirrorResource();
        resource.setId(mirror.getId());
        resource.setUrl(mirror.getUrl());
        dto.addData(resource);
      }
    }

    return dto;
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.MirrorResourceListResponse

    LOG.debug(" getResourceFromResponse: " + responseText);

    representation = new XStreamRepresentation(xstream, responseText, mediaType);

    // this
    MirrorResourceListResponse resourceResponse =
        (MirrorResourceListResponse) representation.getPayload(new MirrorResourceListResponse());

    Assert.assertNotNull("Resource Response shouldn't be null", resourceResponse);

    for (MirrorResource resource : resourceResponse.getData()) {
      Assert.assertNotNull("Id shouldn't be null", resource.getId());
    }

    return resourceResponse;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.