From 3b209d19bbe45e6d1c54c8d2bfc0ef7136f733e2 Mon Sep 17 00:00:00 2001 From: Sharon Shabtai Date: Tue, 10 Jan 2017 10:02:25 -0700 Subject: [PATCH] update sdk to Marquis PFR Indexer v3.1.0.381 --- TpfrClient/Model/IndexStatus.cs | 5 +++ TpfrClient/Model/ReWrapStatus.cs | 2 ++ .../ResponseParsers/IndexResponseParser.cs | 4 ++- .../ReWrapStatusResponseParser.cs | 2 ++ .../TpfrClientIntegrationTest.cs | 33 +++++++++++++++++-- TpfrClientTest/TestFiles/FailedToIndex.xml | 2 +- TpfrClientTest/TestFiles/JobFailed.xml | 2 +- TpfrClientTest/TpfrClientTest.cs | 16 +++++---- 8 files changed, 55 insertions(+), 11 deletions(-) diff --git a/TpfrClient/Model/IndexStatus.cs b/TpfrClient/Model/IndexStatus.cs index 3935832..d4f9053 100644 --- a/TpfrClient/Model/IndexStatus.cs +++ b/TpfrClient/Model/IndexStatus.cs @@ -13,6 +13,8 @@ * **************************************************************************** */ +using System; + namespace TpfrClient.Model { public class IndexStatus @@ -22,6 +24,9 @@ public class IndexStatus public string FileStartTc { get; set; } public string FileDuration { get; set; } public string FileFrameRate { get; set; } + public string ErrorCode { get; set; } + public string ErrorMessage { get; set; } + } public enum IndexResult diff --git a/TpfrClient/Model/ReWrapStatus.cs b/TpfrClient/Model/ReWrapStatus.cs index a56de44..4bc163c 100644 --- a/TpfrClient/Model/ReWrapStatus.cs +++ b/TpfrClient/Model/ReWrapStatus.cs @@ -20,6 +20,8 @@ public class ReWrapStatus public string Error { get; set; } public Phase? Phase { get; set; } public string Percentcomplete { get; set; } + public string ErrorCode { get; set; } + public string ErrorMessage { get; set; } } public enum Phase diff --git a/TpfrClient/ResponseParsers/IndexResponseParser.cs b/TpfrClient/ResponseParsers/IndexResponseParser.cs index 350ab87..aadf9db 100644 --- a/TpfrClient/ResponseParsers/IndexResponseParser.cs +++ b/TpfrClient/ResponseParsers/IndexResponseParser.cs @@ -36,7 +36,9 @@ public IndexStatus Parse(IHttpWebResponse response) IndexTime = element.AttributeTextOrNull("IndexTime"), FileStartTc = element.AttributeTextOrNull("FileStartTC"), FileDuration = element.AttributeTextOrNull("FileDuration"), - FileFrameRate = element.AttributeTextOrNull("FileFrameRate") + FileFrameRate = element.AttributeTextOrNull("FileFrameRate"), + ErrorCode = element.AttributeTextOrNull("errorCode"), + ErrorMessage = element.AttributeTextOrNull("errorStr") }; } } diff --git a/TpfrClient/ResponseParsers/ReWrapStatusResponseParser.cs b/TpfrClient/ResponseParsers/ReWrapStatusResponseParser.cs index 43018b7..a17ae62 100644 --- a/TpfrClient/ResponseParsers/ReWrapStatusResponseParser.cs +++ b/TpfrClient/ResponseParsers/ReWrapStatusResponseParser.cs @@ -35,6 +35,8 @@ public ReWrapStatus Parse(IHttpWebResponse response) Phase = ResponseParseUtils.GetPhaseResult(element.AttributeTextOrNull("phase")), Percentcomplete = element.AttributeTextOrNull("percentcomplete"), Error = element.AttributeTextOrNull("error"), + ErrorCode = element.AttributeTextOrNull("errorCode"), + ErrorMessage = element.AttributeTextOrNull("errorStr") }; } } diff --git a/TpfrClientIntegrationTest/TpfrClientIntegrationTest.cs b/TpfrClientIntegrationTest/TpfrClientIntegrationTest.cs index 5396e71..9354c9d 100644 --- a/TpfrClientIntegrationTest/TpfrClientIntegrationTest.cs +++ b/TpfrClientIntegrationTest/TpfrClientIntegrationTest.cs @@ -58,6 +58,8 @@ public void TestFailedFileIndex() { var status = _client.IndexFile(new IndexFileRequest($"{_path}error.mov")); Assert.AreEqual(IndexResult.Failed, status.IndexResult); + Assert.AreEqual("-2132778994", status.ErrorCode); + Assert.AreEqual(@"Failed to parse MOV file [\\ISV_RETROSPECT1\Share\error.mov] Error [Source could not be opened.]", status.ErrorMessage); } [Test] @@ -108,13 +110,23 @@ public void TestQuestionTimecodeFileNotFound() [Test] public void TestReWrap() { - var firstFrame = new TimeCode("00:00:00:00"); - var lastFrame = new TimeCode("00:00:10:00"); + var firstFrame = new TimeCode("01:00:00;00"); + var lastFrame = new TimeCode("01:00:10;00"); var response = _client.ReWrap(new ReWrapRequest($"{_path}sample.mov", firstFrame, lastFrame, "29.97", $"{_path}sample_10sec.mov", "sampleRestore")); Assert.AreEqual(ReWrapResult.Succeeded, response.Result); } + [Test] + public void TestReWrapWithBadRestoreFile() + { + var firstFrame = new TimeCode("00:00:00;00"); + var lastFrame = new TimeCode("00:00:10;00"); + var response = _client.ReWrap(new ReWrapRequest($"{_path}sample.mov", firstFrame, lastFrame, "29.97", + $"{_path}Sample_10sec.mov", "errorSampleRestore")); + Assert.AreEqual(ReWrapResult.Succeeded, response.Result); + } + [Test] public void TestReWrapErrorBadFramerate() { @@ -132,5 +144,22 @@ public void TestReWrapStatus() var reWrapStatus = _client.ReWrapStatus(new ReWrapStatusRequest("sampleRestore")); Assert.AreEqual(Phase.Complete, reWrapStatus.Phase); } + + [Test] + public void TestReWrapStatusError() + { + var reWrapStatus = _client.ReWrapStatus(new ReWrapStatusRequest("errorSampleRestore")); + Assert.AreEqual(Phase.Failed, reWrapStatus.Phase); + Assert.AreEqual("0", reWrapStatus.Percentcomplete); + Assert.AreEqual("Requested subclip out of bounds.", reWrapStatus.ErrorMessage); + } + + [Test] + public void TestReWrapStatusJobNotFound() + { + var reWrapStatus = _client.ReWrapStatus(new ReWrapStatusRequest("notFound")); + Assert.AreEqual(null, reWrapStatus.Phase); + Assert.AreEqual("Job not found", reWrapStatus.Error); + } } } \ No newline at end of file diff --git a/TpfrClientTest/TestFiles/FailedToIndex.xml b/TpfrClientTest/TestFiles/FailedToIndex.xml index 662ca59..23aec97 100644 --- a/TpfrClientTest/TestFiles/FailedToIndex.xml +++ b/TpfrClientTest/TestFiles/FailedToIndex.xml @@ -1,2 +1,2 @@  - + diff --git a/TpfrClientTest/TestFiles/JobFailed.xml b/TpfrClientTest/TestFiles/JobFailed.xml index dc8e0a9..0f1e4b0 100644 --- a/TpfrClientTest/TestFiles/JobFailed.xml +++ b/TpfrClientTest/TestFiles/JobFailed.xml @@ -1,2 +1,2 @@  - \ No newline at end of file + \ No newline at end of file diff --git a/TpfrClientTest/TpfrClientTest.cs b/TpfrClientTest/TpfrClientTest.cs index 599c852..3cb201f 100644 --- a/TpfrClientTest/TpfrClientTest.cs +++ b/TpfrClientTest/TpfrClientTest.cs @@ -59,11 +59,11 @@ public class TpfrClientTest private static readonly object[] ReWrapStatusObjects = { - new object[] {"JobPending.xml", Phase.Pending, "0"}, - new object[] {"JobParsing.xml", Phase.Parsing, "25"}, - new object[] {"JobTransferring.xml", Phase.Transferring, "50"}, - new object[] {"JobComplete.xml", Phase.Complete, "100"}, - new object[] {"JobFailed.xml", Phase.Failed, "0"} + new object[] {"JobPending.xml", Phase.Pending, "0", null, null}, + new object[] {"JobParsing.xml", Phase.Parsing, "25", null, null}, + new object[] {"JobTransferring.xml", Phase.Transferring, "50", null, null}, + new object[] {"JobComplete.xml", Phase.Complete, "100", null, null}, + new object[] {"JobFailed.xml", Phase.Failed, "0", "-2132778983", "Failed to create file" } }; [Test] @@ -85,7 +85,7 @@ public void TesReWrapError() [Test] [TestCaseSource(nameof(ReWrapStatusObjects))] - public void TesReWrapStatus(string xmlFile, Phase phase, string percentComplete) + public void TesReWrapStatus(string xmlFile, Phase phase, string percentComplete, string errorCode, string errorMessage) { var mockNetwork = new Mock(MockBehavior.Strict); mockNetwork @@ -97,6 +97,8 @@ public void TesReWrapStatus(string xmlFile, Phase phase, string percentComplete) Assert.AreEqual(phase, status.Phase); Assert.AreEqual(percentComplete, status.Percentcomplete); + Assert.AreEqual(errorCode, status.ErrorCode); + Assert.AreEqual(errorMessage, status.ErrorMessage); mockNetwork.VerifyAll(); } @@ -121,6 +123,8 @@ public void TestFailedIndexFile() Assert.AreEqual(IndexResult.Failed, status.IndexResult); Assert.AreEqual("2011/10/21 15:30:15", status.IndexTime); + Assert.AreEqual("400", status.ErrorCode); + Assert.AreEqual("Failed to index", status.ErrorMessage); mockNetwork.VerifyAll(); }