Examples of PlexusComponentListResourceResponse


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

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

  @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

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

  @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

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

  @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

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

  @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

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

    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

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

    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

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

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

    if (userManagers != null) {
      for (BeanEntry<Named, UserManager> entry : userManagers) {
        String hint = entry.getKey().value();
        String description = entry.getDescription();

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

        // add it to the collection
        result.addData(resource);
      }
    }

    if (result.getData().isEmpty()) {
      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND);
    }

    return result;
  }
View Full Code Here

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

  {
    PlexusResource resource = this.lookup(PlexusResource.class, "UserLocatorComponentListPlexusResource");
    Object result = resource.get(null, null, null, null);
    assertThat(result, instanceOf(PlexusComponentListResourceResponse.class));

    PlexusComponentListResourceResponse response = (PlexusComponentListResourceResponse) result;

    assertThat("Result: " + new XStream().toXML(response), response.getData().size(), equalTo(3));

    Map<String, String> data = new HashMap<String, String>();
    for (PlexusComponentListResource item : response.getData()) {
      data.put(item.getRoleHint(), item.getDescription());
    }

    assertThat(data.keySet(), containsInAnyOrder("default", "allConfigured", "MockUserManager"));
    assertThat(data.get("default"), equalTo("Default"));
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.