-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mskcc/develop
Merged.
- Loading branch information
Showing
6 changed files
with
209 additions
and
16 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
Medidata.RWS.NET/Core/Requests/Datasets/VersionDatasetRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Medidata.RWS.Core.Requests; | ||
|
||
namespace Medidata.RWS.Core.Requests.Datasets | ||
{ | ||
public class VersionDatasetRequest : OdmDatasetBase | ||
{ | ||
public VersionDatasetRequest( | ||
|
||
string project_name, | ||
string environment_name, | ||
string version_oid, | ||
string dataset_type = "regular", | ||
string formOid = default(string), | ||
string versionitem = default(string), | ||
string rawsuffix = default(string), | ||
string codelistsuffix = default(string), | ||
string decodesuffix = default(string), | ||
string stdsuffix = default(string), | ||
string start = default(string)) : base(dataset_type, versionitem, rawsuffix, codelistsuffix, decodesuffix, stdsuffix, start) | ||
{ | ||
|
||
ProjectName = project_name; | ||
EnvironmentName = environment_name; | ||
VersionOid = version_oid; | ||
FormOid = formOid; | ||
Verify(); | ||
} | ||
|
||
public string VersionOid { get; set; } | ||
|
||
public string FormOid { get; set; } | ||
|
||
public string EnvironmentName { get; set; } | ||
|
||
public string ProjectName { get; set; } | ||
|
||
/// <summary> | ||
/// Get the Study and Environment names in a format RWS expects. | ||
/// If no environment name is provided, it is left out of the return string. | ||
/// </summary> | ||
/// <returns></returns> | ||
private string StudyNameAndEnvironment() | ||
{ | ||
return string.IsNullOrWhiteSpace(EnvironmentName) ? $"{ProjectName}" : $"{ProjectName}({EnvironmentName})"; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// The URL path of the resource being requested. | ||
/// </summary> | ||
/// <returns></returns> | ||
public override string UrlPath() | ||
{ | ||
|
||
var queryParams = new List<string> { "studies", StudyNameAndEnvironment(), "versions", VersionOid, "datasets", dataset_type }; | ||
|
||
if (!string.IsNullOrEmpty(FormOid)) queryParams.Add(FormOid); | ||
|
||
return RequestHelpers.MakeUrl("/", QueryString(), queryParams.ToArray()); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Medidata.RWS.Tests/Core/Requests/Datasets/VersionDatasetRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using Medidata.RWS.Core.Requests.Datasets; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Medidata.RWS.Tests.Core.Requests.Datasets | ||
{ | ||
[TestClass] | ||
public class VersionDatasetRequestTests | ||
{ | ||
[TestMethod] | ||
public void VersionDatasetRequest_default_version_path_is_correct() | ||
{ | ||
var request = new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "001"); | ||
|
||
Assert.AreEqual("Mediflex", request.ProjectName); | ||
|
||
Assert.AreEqual("Dev", request.EnvironmentName); | ||
|
||
Assert.AreEqual("001", request.VersionOid); | ||
|
||
Assert.AreEqual("studies/Mediflex(Dev)/versions/001/datasets/regular", request.UrlPath()); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void VersionDatasetRequest_raw_version_path_is_correct() | ||
{ | ||
var request = new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "001", dataset_type:"raw"); | ||
|
||
Assert.AreEqual("Mediflex", request.ProjectName); | ||
|
||
Assert.AreEqual("Dev", request.EnvironmentName); | ||
|
||
Assert.AreEqual("001", request.VersionOid); | ||
|
||
Assert.AreEqual("studies/Mediflex(Dev)/versions/001/datasets/raw", request.UrlPath()); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void VersionDatasetRequest_raw_version_path_with_form_is_correct() | ||
{ | ||
var request = new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "001", dataset_type: "raw", formOid: "DM"); | ||
|
||
Assert.AreEqual("Mediflex", request.ProjectName); | ||
|
||
Assert.AreEqual("Dev", request.EnvironmentName); | ||
|
||
Assert.AreEqual("001", request.VersionOid); | ||
|
||
Assert.AreEqual("studies/Mediflex(Dev)/versions/001/datasets/raw/DM", request.UrlPath()); | ||
|
||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(NotSupportedException))] | ||
public void VersionDatasetRequest_throws_with_improper_parameters() | ||
{ | ||
|
||
var req = new VersionDatasetRequest("TESTPROJECT", "DEV", "1001", dataset_type: "newfie"); | ||
|
||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters