Permalink
Browse files

initial check in for remaining model unit tests.

  • Loading branch information...
1 parent 50fe300 commit 1bdbc7c8b59924e3e07ce3329d856ff4471e4ca4 Albert Cheng committed Dec 18, 2012
@@ -92,159 +92,179 @@ public String getId() {
return id;
}
- public void setId(String id) {
+ public TaskType setId(String id) {
this.id = id;
+ return this;
}
public String getConfiguration() {
return configuration;
}
- public void setConfiguration(String configuration) {
+ public TaskType setConfiguration(String configuration) {
this.configuration = configuration;
+ return this;
}
public Date getEndTime() {
return endTime;
}
- public void setEndTime(Date endTime) {
+ public TaskType setEndTime(Date endTime) {
this.endTime = endTime;
+ return this;
}
public String getErrorDetails() {
return errorDetails;
}
- public void setErrorDetails(String errorDetails) {
+ public TaskType setErrorDetails(String errorDetails) {
this.errorDetails = errorDetails;
+ return this;
}
public String getMediaProcessorId() {
return mediaProcessorId;
}
- public void setMediaProcessorId(String mediaProcessorId) {
+ public TaskType setMediaProcessorId(String mediaProcessorId) {
this.mediaProcessorId = mediaProcessorId;
+ return this;
}
public String getName() {
return name;
}
- public void setName(String name) {
+ public TaskType setName(String name) {
this.name = name;
+ return this;
}
public String getPerfMessage() {
return perfMessage;
}
- public void setPerfMessage(String perfMessage) {
+ public TaskType setPerfMessage(String perfMessage) {
this.perfMessage = perfMessage;
+ return this;
}
public Integer getPriority() {
return priority;
}
- public void setPriority(Integer priority) {
+ public TaskType setPriority(Integer priority) {
this.priority = priority;
+ return this;
}
public Double getProgress() {
return progress;
}
- public void setProgress(Double progress) {
+ public TaskType setProgress(Double progress) {
this.progress = progress;
+ return this;
}
public Double getRunningDuration() {
return runningDuration;
}
- public void setRunningDuration(Double runningDuration) {
+ public TaskType setRunningDuration(Double runningDuration) {
this.runningDuration = runningDuration;
+ return this;
}
public Date getStartTime() {
return startTime;
}
- public void setStartTime(Date startTime) {
+ public TaskType setStartTime(Date startTime) {
this.startTime = startTime;
+ return this;
}
public Integer getState() {
return state;
}
- public void setState(Integer state) {
+ public TaskType setState(Integer state) {
this.state = state;
+ return this;
}
public String getTaskBody() {
return taskBody;
}
- public void setTaskBody(String taskBody) {
+ public TaskType setTaskBody(String taskBody) {
this.taskBody = taskBody;
+ return this;
}
public Integer getOptions() {
return options;
}
- public void setOptions(Integer options) {
+ public TaskType setOptions(Integer options) {
this.options = options;
+ return this;
}
public String getEncryptionKeyId() {
return encryptionKeyId;
}
- public void setEncryptionKeyId(String encryptionKeyId) {
+ public TaskType setEncryptionKeyId(String encryptionKeyId) {
this.encryptionKeyId = encryptionKeyId;
+ return this;
}
public String getEncryptionScheme() {
return encryptionScheme;
}
- public void setEncryptionScheme(String encryptionScheme) {
+ public TaskType setEncryptionScheme(String encryptionScheme) {
this.encryptionScheme = encryptionScheme;
+ return this;
}
public String getEncryptionVersion() {
return encryptionVersion;
}
- public void setEncryptionVersion(String encryptionVersion) {
+ public TaskType setEncryptionVersion(String encryptionVersion) {
this.encryptionVersion = encryptionVersion;
+ return this;
}
public String getInitializationVector() {
return initializationVector;
}
- public void setInitializationVector(String initializationVector) {
+ public TaskType setInitializationVector(String initializationVector) {
this.initializationVector = initializationVector;
+ return this;
}
public List<String> getOutputMediaAssets() {
return outputMediaAssets;
}
- public void setOutputMediaAssets(List<String> outputMediaAssets) {
+ public TaskType setOutputMediaAssets(List<String> outputMediaAssets) {
this.outputMediaAssets = outputMediaAssets;
+ return this;
}
public List<String> getInputMediaAssets() {
return inputMediaAssets;
}
- public void setInputMediaAssets(List<String> inputMediaAssets) {
+ public TaskType setInputMediaAssets(List<String> inputMediaAssets) {
this.inputMediaAssets = inputMediaAssets;
+ return this;
}
}
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2012 Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.microsoft.windowsazure.services.media.models;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.mail.BodyPart;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMultipart;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.xml.bind.JAXBException;
+
+import org.junit.Test;
+
+import com.microsoft.windowsazure.services.core.ServiceException;
+import com.microsoft.windowsazure.services.media.implementation.ODataAtomUnmarshaller;
+import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+
+/**
+ * Tests for the methods and factories of the Job entity.
+ */
+public class JobEntityTest {
+
+ private JobInfo getJobInfo(MimeMultipart payload) throws MessagingException, IOException, JAXBException,
+ ServiceException {
+ for (int i = 0; i < payload.getCount(); i++) {
+ BodyPart bodyPart = payload.getBodyPart(i);
+ JobInfo jobInfo = parseBodyPart(bodyPart);
+ if (jobInfo != null) {
+ return jobInfo;
+ }
+ }
+
+ return null;
+ }
+
+ private JobInfo parseBodyPart(BodyPart bodyPart) throws IOException, MessagingException, JAXBException,
+ ServiceException {
+ JobInfo jobInfo = null;
+ ODataAtomUnmarshaller oDataAtomUnmarshaller = new ODataAtomUnmarshaller();
+ InputStream inputStream = bodyPart.getInputStream();
+ jobInfo = oDataAtomUnmarshaller.unmarshalEntry(inputStream, JobInfo.class);
+ return jobInfo;
+ }
+
+ public JobEntityTest() throws Exception {
+ }
+
+ @Test
+ public void JobCreateReturnsDefaultCreatePayload() throws ServiceException {
+ MimeMultipart payload = (MimeMultipart) Job.create().getRequestContents();
+ assertNotNull(payload);
+ }
+
+ @Test
+ public void JobCreateCanSetJobName() throws ServiceException, MessagingException, IOException, JAXBException {
+ String expectedName = "JobCreateCanSetJobName";
+
+ Job.Creator creator = Job.create().setName(expectedName);
+
+ MimeMultipart payload = (MimeMultipart) creator.getRequestContents();
+
+ JobInfo jobInfo = getJobInfo(payload);
+
+ assertEquals(expectedName, jobInfo.getName());
+ }
+
+ @Test
+ public void JobListReturnsExpectedUri() {
+ EntityListOperation<JobInfo> lister = Job.list();
+
+ assertEquals("Jobs", lister.getUri());
+ assertNotNull(lister.getQueryParameters());
+ assertEquals(0, lister.getQueryParameters().size());
+ }
+
+ @Test
+ public void JobListCanTakeQueryParameters() {
+ MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
+ queryParams.add("$top", "10");
+ queryParams.add("$skip", "2");
+
+ EntityListOperation<JobInfo> lister = Job.list(queryParams);
+
+ assertEquals("10", lister.getQueryParameters().getFirst("$top"));
+ assertEquals("2", lister.getQueryParameters().getFirst("$skip"));
+ assertEquals(2, lister.getQueryParameters().size());
+ }
+
+ @Test
+ public void JobListCanTakeQueryParametersChained() {
+ EntityListOperation<JobInfo> lister = Job.list().setTop(10).setSkip(2).set("filter", "something");
+
+ assertEquals("10", lister.getQueryParameters().getFirst("$top"));
+ assertEquals("2", lister.getQueryParameters().getFirst("$skip"));
+ assertEquals("something", lister.getQueryParameters().getFirst("filter"));
+ assertEquals(3, lister.getQueryParameters().size());
+ }
+
+}
Oops, something went wrong.

0 comments on commit 1bdbc7c

Please sign in to comment.