Package org.sonatype.nexus.rest.model

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


  {
    String responseString = this.sendMessage(role, xstream, mediaType).getEntity().getText();

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

    PlexusComponentListResourceResponse resourceResponse =
        (PlexusComponentListResourceResponse) representation.getPayload(new PlexusComponentListResourceResponse());

    return resourceResponse.getData();
  }
View Full Code Here


  @Test
  public void testValidRoleMultipleResults()
      throws Exception
  {
    PlexusComponentListResourceResponse result = runGetForRole(PlexusResource.class.getName());

    Assert.assertTrue(result.getData().size() > 1); // expected a bunch of these thing, with new ones being
    // added all the time.

    // now for a more controled test
    result = runGetForRole("MULTI_TEST");
    Assert.assertEquals(2, result.getData().size());

    // the order is undefined
    PlexusComponentListResource resource1 = null;
    PlexusComponentListResource resource2 = null;

    for (PlexusComponentListResource resource : (List<PlexusComponentListResource>) result.getData()) {
      if (resource.getRoleHint().endsWith("1")) {
        resource1 = resource;
      }
      else {
        resource2 = resource;
View Full Code Here

  @Test
  public void testValidRoleSingleResult()
      throws Exception
  {
    PlexusComponentListResourceResponse result = runGetForRole("TEST_ROLE");

    Assert.assertTrue(result.getData().size() == 1);

    PlexusComponentListResource resource = (PlexusComponentListResource) result.getData().get(0);

    Assert.assertEquals("Test Description.", resource.getDescription());
    Assert.assertEquals("test-hint", resource.getRoleHint());
  }
View Full Code Here

  @Test
  public void testNullDescriptionAndHint()
      throws Exception
  {
    PlexusComponentListResourceResponse result = runGetForRole("TEST_NULL");

    Assert.assertTrue(result.getData().size() == 1);

    PlexusComponentListResource resource = (PlexusComponentListResource) result.getData().get(0);

    Assert.assertEquals("default", resource.getDescription());
    Assert.assertEquals("default", resource.getRoleHint());
  }
View Full Code Here

  @Test
  public void testEmptyDescriptionAndHint()
      throws Exception
  {
    PlexusComponentListResourceResponse result = runGetForRole("TEST_EMPTY");

    Assert.assertTrue(result.getData().size() == 1);

    PlexusComponentListResource resource = (PlexusComponentListResource) result.getData().get(0);

    Assert.assertEquals("default", resource.getDescription());
    Assert.assertEquals("default", resource.getRoleHint());
  }
View Full Code Here

    this.validateXmlHasNoPackageNames(response);
  }

  @Test
  public void testPlexusComponentListResourceResponse() {
    PlexusComponentListResourceResponse resourceResponse = new PlexusComponentListResourceResponse();

    PlexusComponentListResource resource1 = new PlexusComponentListResource();
    resource1.setDescription("description1");
    resource1.setRoleHint("role-hint1");
    resourceResponse.addData(resource1);

    PlexusComponentListResource resource2 = new PlexusComponentListResource();
    resource2.setDescription("description2");
    resource2.setRoleHint("role-hint2");
    resourceResponse.addData(resource2);

    this.marshalUnmarchalThenCompare(resourceResponse);
    this.validateXmlHasNoPackageNames(resourceResponse);

  }
View Full Code Here

    return request.getAttributes().get(ROLE_ID).toString();
  }

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

    // get role from request
    String role = getRole(request);

    try {
      Key<?> roleKey = Key.get(uberClassLoader.loadClass(role), Named.class);
      Iterable<? extends BeanEntry<Named, ?>> components = beanLocator.locate(roleKey);

      if (!components.iterator().hasNext()) {
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND);
      }

      for (BeanEntry<Named, ?> entry : components) {
        PlexusComponentListResource resource = new PlexusComponentListResource();

        String hint = entry.getKey().value();
        String description = entry.getDescription();

        resource.setRoleHint(hint);
        resource.setDescription(StringUtils.isNotEmpty(description) ? description : hint);

        // add it to the collection
        result.addData(resource);
      }
    }
    catch (ClassNotFoundException | LinkageError e) {
      if (this.getLogger().isDebugEnabled()) {
        getLogger().debug("Unable to look up plexus component with role '" + role + "'.", e);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.PlexusComponentListResourceResponse

Copyright © 2018 www.massapicom. 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.