Package org.sonatype.nexus.rest.model

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


  }

  public Status create(ScheduledServiceBaseResource task, Matcher<Response>... matchers)
      throws IOException
  {
    ScheduledServiceResourceResponse request = new ScheduledServiceResourceResponse();
    request.setData(task);

    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", MediaType.APPLICATION_XML);
    representation.setPayload(request);

    String serviceURI = "service/local/schedules";
View Full Code Here


  }

  public Status update(ScheduledServiceBaseResource task, Matcher<Response>... matchers)
      throws IOException
  {
    ScheduledServiceResourceResponse request = new ScheduledServiceResourceResponse();
    request.setData(task);

    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", MediaType.APPLICATION_XML);
    representation.setPayload(request);

    String serviceURI = "service/local/schedules/" + task.getId();
View Full Code Here

    String jsonString =
        "{\"data\":{\"id\":null,\"name\":\"test\",\"typeId\":\"Synchronize Repositories\",\"schedule\":\"none\"}}}";
    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("none");
  }
View Full Code Here

    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");
    assert ((ScheduledServiceOnceResource) response.getData()).getStartDate().equals("1210651200000");
    assert ((ScheduledServiceOnceResource) response.getData()).getStartTime().equals("12:30");
  }
View Full Code Here

    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");
    assert ((ScheduledServiceDailyResource) response.getData()).getStartDate().equals("1210651200000");
    assert ((ScheduledServiceDailyResource) response.getData()).getRecurringTime().equals("12:30");
  }
View Full Code Here

  }

  public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {

    // removes the class="class.name" attribute
    ScheduledServiceResourceResponse top = (ScheduledServiceResourceResponse) value;
    if (top.getData() != null) {
      // make sure the data's repoType field is valid, or we wont be able to deserialize it on the other side
      if (StringUtils.isEmpty(top.getData().getSchedule())) {
        throw new ConversionException("Missing value for field: ScheduledServiceResourceResponse.data.schedule.");
      }

      writer.startNode("data");
      context.convertAnother(top.getData());
      writer.endNode();
    }

  }
View Full Code Here

    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");
    assert ((ScheduledServiceWeeklyResource) response.getData()).getStartDate().equals("1210651200000");
    assert ((ScheduledServiceWeeklyResource) response.getData()).getRecurringTime().equals("12:30");
  }
View Full Code Here

    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");
    assert ((ScheduledServiceMonthlyResource) response.getData()).getStartDate().equals("1210651200000");
    assert ((ScheduledServiceMonthlyResource) response.getData()).getRecurringTime().equals("12:30");
  }
View Full Code Here

    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");
    assert ((ScheduledServiceAdvancedResource) response.getData()).getCronCommand().equals("somecroncommand");
  }
View Full Code Here

    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");
    assert response.getData().getProperties().size() == 1;
    assert ((ScheduledServicePropertyResource) response.getData().getProperties().get(0)).getKey().equals("1");
    assert ((ScheduledServicePropertyResource) response.getData().getProperties().get(0)).getValue().equals(
        "true");
    assert ((ScheduledServiceAdvancedResource) response.getData()).getCronCommand().equals("somecroncommand");
  }
View Full Code Here

TOP

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

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.