Package org.sonatype.plexus.rest.representation

Examples of org.sonatype.plexus.rest.representation.XStreamRepresentation


  public void testOnceScheduledService()
      throws Exception
  {
    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"once\",\"startDate\":\"1210651200000\",\"startTime\":\"12:30\"}}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse response =
        (ScheduledServiceResourceResponse) representation.getPayload(new ScheduledServiceResourceResponse());

    assert response.getData().getId() == null;
    assert response.getData().getName().equals("test");
    assert response.getData().getTypeId().equals("Synchronize Repositories");
    assert response.getData().getSchedule().equals("once");
View Full Code Here


  public void testDailyScheduledService()
      throws Exception
  {
    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"daily\",\"startDate\":\"1210651200000\",\"recurringTime\":\"12:30\"}}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse response =
        (ScheduledServiceResourceResponse) representation.getPayload(new ScheduledServiceResourceResponse());

    assert response.getData().getId() == null;
    assert response.getData().getName().equals("test");
    assert response.getData().getTypeId().equals("Synchronize Repositories");
    assert response.getData().getSchedule().equals("daily");
View Full Code Here

  public void testWeeklyScheduledService()
      throws Exception
  {
    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"weekly\",\"startDate\":\"1210651200000\",\"recurringTime\":\"12:30\",\"recurringDay\":[\"Monday\",\"Wednesday\"]}}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse response =
        (ScheduledServiceResourceResponse) representation.getPayload(new ScheduledServiceResourceResponse());

    assert response.getData().getId() == null;
    assert response.getData().getName().equals("test");
    assert response.getData().getTypeId().equals("Synchronize Repositories");
    assert response.getData().getSchedule().equals("weekly");
View Full Code Here

  public void testMonthlyScheduledService()
      throws Exception
  {
    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"monthly\",\"startDate\":\"1210651200000\",\"recurringTime\":\"12:30\",\"recurringDay\":[\"1\",\"2\"]}}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse response =
        (ScheduledServiceResourceResponse) representation.getPayload(new ScheduledServiceResourceResponse());

    assert response.getData().getId() == null;
    assert response.getData().getName().equals("test");
    assert response.getData().getTypeId().equals("Synchronize Repositories");
    assert response.getData().getSchedule().equals("monthly");
View Full Code Here

  public void testAdvancedScheduledService()
      throws Exception
  {
    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"advanced\",\"cronCommand\":\"somecroncommand\"}}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse response =
        (ScheduledServiceResourceResponse) representation.getPayload(new ScheduledServiceResourceResponse());

    assert response.getData().getId() == null;
    assert response.getData().getName().equals("test");
    assert response.getData().getTypeId().equals("Synchronize Repositories");
    assert response.getData().getSchedule().equals("advanced");
View Full Code Here

  public void testAdvancedScheduledServiceWithProperties()
      throws Exception
  {
    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"advanced\",\"cronCommand\":\"somecroncommand\",\"properties\":[{\"key\":\"1\",\"value\":\"true\",\"@class\":\"org.sonatype.nexus.rest.model.ScheduledServicePropertyResource\"}]}}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse response =
        (ScheduledServiceResourceResponse) representation.getPayload(new ScheduledServiceResourceResponse());

    assert response.getData().getId() == null;
    assert response.getData().getName().equals("test");
    assert response.getData().getTypeId().equals("Synchronize Repositories");
    assert response.getData().getSchedule().equals("advanced");
View Full Code Here

      throws Exception
  {
    String jsonString =
        "{\"data\":{\"name\":\"Test Priv\",\"type\":\"target\",\"method\":[\"read\",\"create\"],"
            + "\"repositoryTargetId\":\"targetId\",\"repositoryId\":\"repoId\",\"repositoryGroupId\":\"groupId\"}}";
    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    PrivilegeResourceRequest request =
        (PrivilegeResourceRequest) representation.getPayload(new PrivilegeResourceRequest());

    assert request.getData().getName().equals("Test Priv");
    assert request.getData().getType().equals(TargetPrivilegeDescriptor.TYPE);
    assert request.getData().getMethod().size() == 2;
    assert request.getData().getMethod().contains("read");
View Full Code Here

  public void testRepoGroup()
      throws Exception
  {
    String jsonString = "{\"data\":[{\"id\":\"public-releases\",\"name\":\"public-releases11\"}]}";

    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    RepositoryGroupListResourceResponse response =
        (RepositoryGroupListResourceResponse) representation.getPayload(new RepositoryGroupListResourceResponse());
  }
View Full Code Here

    Response response = null;
    try {
      response = RequestFacade.sendMessage(
          RequestFacade.SERVICE_LOCAL + "ldap/logintest",
          Method.PUT,
          new XStreamRepresentation(
              xstream,
              xstream.toXML(ldapServerLoginTestRequest),
              MediaType.APPLICATION_XML));

      String responseText = response.getEntity().getText();
View Full Code Here

  public Response sendMessage(Method method, UserToRoleResource resource, String source)
      throws IOException
  {

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

    String serviceURI = USER_ROLES_SERVICE_PART + "/" + source + "/" + resource.getUserId();

    UserToRoleResourceRequest repoResponseRequest = new UserToRoleResourceRequest();
    repoResponseRequest.setData(resource);

    // now set the payload
    representation.setPayload(repoResponseRequest);

    LOG.debug("sendMessage: {}", representation.getText());

    return RequestFacade.sendMessage(serviceURI, method, representation);
  }
View Full Code Here

TOP

Related Classes of org.sonatype.plexus.rest.representation.XStreamRepresentation

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.