Skip to content

Commit

Permalink
address code review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Cheng committed Oct 26, 2012
1 parent b71feaf commit a08f46c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,11 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions
*
* @param jobId
* the job id
* @return
* @throws ServiceException
* the service exception
*/
public void cancelJob(String jobId) throws ServiceException;
public JobInfo cancelJob(String jobId) throws ServiceException;

/**
* List tasks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOpt
* @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String)
*/
@Override
public void cancelJob(String jobId) throws ServiceException {
public JobInfo cancelJob(String jobId) throws ServiceException {
try {
service.cancelJob(jobId);
return service.cancelJob(jobId);
}
catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;

// TODO: Auto-generated Javadoc
/**
* The Class MediaRestProxy.
*/
Expand Down Expand Up @@ -237,6 +236,19 @@ private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T
return builder.post(c, requestEntity);
}

private ListTasksResult listWebResourceTasks(WebResource webResource, ListTasksOptions listTasksOptions) {
if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) {
webResource = webResource.queryParams(listTasksOptions.getQueryParameters());
}

List<TaskInfo> taskInfoList = webResource.type(MediaType.APPLICATION_ATOM_XML)
.accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() {
});
ListTasksResult listTasksResult = new ListTasksResult();
listTasksResult.setTaskInfos(taskInfoList);
return listTasksResult;
}

/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.MediaContract#createAsset()
*/
Expand Down Expand Up @@ -580,9 +592,9 @@ public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOpt
* @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String)
*/
@Override
public void cancelJob(String jobId) throws ServiceException {
public JobInfo cancelJob(String jobId) throws ServiceException {
try {
getResource("Jobs", jobId).delete();
return getResource("CancelJob").queryParam("jobId", jobId).get(JobInfo.class);
}
catch (UniformInterfaceException e) {
throw new ServiceException(e);
Expand Down Expand Up @@ -623,18 +635,7 @@ public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceEx
@Override
public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException {
WebResource resource = getResource("Tasks");

if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) {
resource = resource.queryParams(listTasksOptions.getQueryParameters());
}

List<TaskInfo> taskInfoList = resource.type(MediaType.APPLICATION_ATOM_XML)
.accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() {
});
ListTasksResult listTasksResult = new ListTasksResult();
listTasksResult.setTaskInfos(taskInfoList);
return listTasksResult;

return listWebResourceTasks(resource, listTasksOptions);
}

/* (non-Javadoc)
Expand All @@ -643,17 +644,7 @@ public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws Servi
@Override
public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException {
WebResource resource = getResource("Jobs", "Tasks", jobId);

if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) {
resource = resource.queryParams(listTasksOptions.getQueryParameters());
}

List<TaskInfo> taskInfoList = resource.type(MediaType.APPLICATION_ATOM_XML)
.accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() {
});
ListTasksResult listTasksResult = new ListTasksResult();
listTasksResult.setTaskInfos(taskInfoList);
return listTasksResult;
return listWebResourceTasks(resource, listTasksOptions);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void setVendor(String vendor) {
}

public String getVersion() {
return null;
return this.version;
}

public void setVersion(String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public class TaskType implements MediaServiceDTO {
protected String perfMessage;

@XmlElement(name = "Priority", namespace = Constants.ODATA_DATA_NS)
protected int priority;
protected Integer priority;

@XmlElement(name = "Progress", namespace = Constants.ODATA_DATA_NS)
protected double progress;
protected Double progress;

@XmlElement(name = "RunningDuration", namespace = Constants.ODATA_DATA_NS)
protected double runningDuration;
protected Double runningDuration;

@XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS)
protected Date startTime;

@XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS)
protected int state;
protected Integer state;

@XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS)
protected String taskBody;
Expand Down Expand Up @@ -145,27 +145,27 @@ public void setPerfMessage(String perfMessage) {
this.perfMessage = perfMessage;
}

public int getPriority() {
public Integer getPriority() {
return priority;
}

public void setPriority(int priority) {
public void setPriority(Integer priority) {
this.priority = priority;
}

public double getProgress() {
public Double getProgress() {
return progress;
}

public void setProgress(double progress) {
public void setProgress(Double progress) {
this.progress = progress;
}

public double getRunningDuration() {
public Double getRunningDuration() {
return runningDuration;
}

public void setRunningDuration(double runningDuration) {
public void setRunningDuration(Double runningDuration) {
this.runningDuration = runningDuration;
}

Expand All @@ -177,11 +177,11 @@ public void setStartTime(Date startTime) {
this.startTime = startTime;
}

public int getState() {
public Integer getState() {
return state;
}

public void setState(int state) {
public void setState(Integer state) {
this.state = state;
}

Expand All @@ -193,11 +193,11 @@ public void setTaskBody(String taskBody) {
this.taskBody = taskBody;
}

public int getOptions() {
public Integer getOptions() {
return options;
}

public void setOptions(int options) {
public void setOptions(Integer options) {
this.options = options;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public TaskInfo setPerfMessage(String perfMessage) {
*
* @return the priority
*/
public int getPriority() {
public Integer getPriority() {
return getContent().getPriority();
}

Expand All @@ -208,7 +208,7 @@ public int getPriority() {
* the priority
* @return the task info
*/
public TaskInfo setPriority(int priority) {
public TaskInfo setPriority(Integer priority) {
getContent().setPriority(priority);
return this;
}
Expand All @@ -218,18 +218,17 @@ public TaskInfo setPriority(int priority) {
*
* @return the progress
*/
public double getProgress() {
public Double getProgress() {
return getContent().getProgress();
}

/**
* Sets the progress.
*
* @param progress
* the progress
* @return the task info
*/
public TaskInfo setProgress(int progress) {
public TaskInfo setProgress(Double progress) {
getContent().setProgress(progress);
return this;
}
Expand Down Expand Up @@ -281,7 +280,7 @@ public TaskInfo setStartTime(Date startTime) {
*
* @return the state
*/
public int getState() {
public Integer getState() {
return getContent().getState();
}

Expand All @@ -292,7 +291,7 @@ public int getState() {
* the state
* @return the task info
*/
public TaskInfo setState(int state) {
public TaskInfo setState(Integer state) {
getContent().setState(state);
return this;
}
Expand Down Expand Up @@ -323,7 +322,7 @@ public TaskInfo setTaskBody(String taskBody) {
*
* @return the options
*/
public int getOptions() {
public Integer getOptions() {
return getContent().getOptions();
}

Expand All @@ -334,7 +333,7 @@ public int getOptions() {
* the options
* @return the task info
*/
public TaskInfo setOptions(int options) {
public TaskInfo setOptions(Integer options) {
getContent().setOptions(options);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException {
assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0);
}

@Ignore
@Test
public void createJobWithTaskInfoSuccess() throws ServiceException {
// Arrange
Expand All @@ -534,6 +535,7 @@ public void createJobWithTaskInfoSuccess() throws ServiceException {
assertNotNull(jobInfo);
}

@Ignore
@Test
public void listJobsSuccess() throws ServiceException {
// Arrange
Expand All @@ -550,6 +552,7 @@ public void listJobsSuccess() throws ServiceException {
assertNotNull(listJobsResult);
}

@Ignore
@Test
public void listTopJobsSuccess() throws ServiceException {
// Arrange
Expand All @@ -566,6 +569,7 @@ public void listTopJobsSuccess() throws ServiceException {

}

@Ignore
@Test
public void cancelJobSuccess() throws ServiceException {
// Arrange
Expand All @@ -590,6 +594,7 @@ public void cancelInvalidJobFailed() throws ServiceException {
// Assert
}

@Ignore
@Test
public void listTasksSuccess() throws ServiceException {
// Arrange
Expand All @@ -606,6 +611,7 @@ public void listTasksSuccess() throws ServiceException {

}

@Ignore
@Test
public void listTasksWithOptionsSuccess() throws ServiceException {
// Arrange
Expand All @@ -623,6 +629,7 @@ public void listTasksWithOptionsSuccess() throws ServiceException {
assertEquals(1, listTasksResult.getTaskInfos().size());
}

@Ignore
@Test
public void listJobTasksSuccess() throws ServiceException {
// Arrange
Expand All @@ -637,6 +644,7 @@ public void listJobTasksSuccess() throws ServiceException {
assertNotNull(listTasksResult);
}

@Ignore
@Test
public void listJobTasksInvalidIdFailed() throws ServiceException {
// Arrange
Expand All @@ -649,6 +657,7 @@ public void listJobTasksInvalidIdFailed() throws ServiceException {

}

@Ignore
@Test
public void listJobTasksSuccessWithOptionsSuccess() throws ServiceException {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ public void testGetSetName() {
assertEquals(expectedJobName, actualJobName);
}

@Test
public void testGetSetEndTime() {
// Arrange
String expectedJobName = "testGetSetNameJobName";
CreateJobOptions createJobOptions = new CreateJobOptions();

// Act
String actualJobName = createJobOptions.setName(expectedJobName).getName();

// Assert
assertEquals(expectedJobName, actualJobName);
}

@Test
public void testGetSetPriority() {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testGetSetVersion() {
MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo();

// Act
String actualVersion = mediaProcessorInfo.setName(expectedVersion).getVersion();
String actualVersion = mediaProcessorInfo.setVersion(expectedVersion).getVersion();

// Assert
assertEquals(expectedVersion, actualVersion);
Expand Down

0 comments on commit a08f46c

Please sign in to comment.