<commit_before>!define TEST_SYSTEM {slim}
!define file {4}


!3 Generate Random Variables 
!|Table: Rest Fixture | $baseURL |
|let|sName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|sName2|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|sName3|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|createPostName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|updatedName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|iName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||

!3 Create Sample
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$createPostName" }|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study |200|  Content-Type: application/json ||
|let|sampleId|js|response.jsonbody.response[0].result[0].id||

!3 Create Second Sample Including Individual And Annotation (Deprecated)
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$sName2", "individual" : {"name":"$iName"}, "annotationSets":[{"name": "string", "variableSet": "$gVariableSetId",  "annotations": {"var_int": "10"}}]}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study&lazy=false |200|  Content-Type: application/json ||
|let|sampleId2|js|response.jsonbody.response[0].result[0].id||
|let||js|response.jsonbody.response[0].result[0].annotationSets[0].annotations[1].value|10|

!3 Search Individual Created Inside the Sample Using Individual Name
!|Table: Rest Fixture | $baseURL |
| GET | /v1/individuals/search?sid=$sessionId&study=$study&name=$iName|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$iName'|
|let|individualId|js|response.jsonbody.response[0].result[0].id||

!3 (Negative) Create Sample Including Individual And Annotation With Invalid Variable Set 
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$sName3", "individual" : {"name":"$iName"}, "annotationSets":[{"name": "string", "variableSet": "variableSetId",  "annotations": {"var_int": "10"}}]}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study |500|  Content-Type: application/json ||

!3 (Negative) Create Sample Including Annotation With Missing Mandatory Variable
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$sName3", "individual" : {"name":"$iName"}, "annotationSets":[{"name": "string", "variableSet": "$gVariableSetId",  "annotations": {"var_double": "100.5"}}]}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study |500|  Content-Type: application/json |jsonbody.error == 'Missing required variable var_int'|

!3 Get Sample 
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/$sampleId/info?sid=$sessionId|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].id == '$sampleId'|

!3 Get Individual 
!|Table: Rest Fixture | $baseURL |
| GET | /v1/individuals/$individualId/info?sid=$sessionId|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].id == '$individualId'|

!3 Update Sample (POST)
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$updatedName" }|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/$sampleId/update?sid=$sessionId |200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$updatedName'|

!3 Get Sample 
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/$sampleId/info?sid=$sessionId|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$updatedName'|

!3 Get Samples as Groups
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/groupBy?sid=$sessionId&study=$study&fields=name%2Csource&limit=5|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].numResults > '0' && jsonbody.response[0].result[0]._id.name != ''|

!3 Get Sample ACL
!|Table: Rest Fixture | $baseURL |<commit_msg>Test: added tests for version in sample<commit_after>!define TEST_SYSTEM {slim}

!3 Generate Random Variables 
!|Table: Rest Fixture | $baseURL |
|let|sName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|sName2|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|sName3|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|createPostName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|updatedName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||
|let|iName|js|Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)||

!3 Create Sample
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$createPostName" }|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study |200|  Content-Type: application/json ||
|let|sampleId|js|response.jsonbody.response[0].result[0].id||

!3 Create Second Sample Including Individual And Annotation (Deprecated)
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$sName2", "individual" : {"name":"$iName"}, "annotationSets":[{"name": "string", "variableSet": "$gVariableSetId",  "annotations": {"var_int": "10"}}]}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study&lazy=false |200|  Content-Type: application/json ||
|let|sampleId2|js|response.jsonbody.response[0].result[0].id||
|let||js|response.jsonbody.response[0].result[0].annotationSets[0].annotations[1].value|10|

!3 Search Individual Created Inside the Sample Using Individual Name
!|Table: Rest Fixture | $baseURL |
| GET | /v1/individuals/search?sid=$sessionId&study=$study&name=$iName|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$iName'|
|let|individualId|js|response.jsonbody.response[0].result[0].id||

!3 (Negative) Create Sample Including Individual And Annotation With Invalid Variable Set 
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$sName3", "individual" : {"name":"$iName"}, "annotationSets":[{"name": "string", "variableSet": "variableSetId",  "annotations": {"var_int": "10"}}]}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study |500|  Content-Type: application/json ||

!3 (Negative) Create Sample Including Annotation With Missing Mandatory Variable
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$sName3", "individual" : {"name":"$iName"}, "annotationSets":[{"name": "string", "variableSet": "$gVariableSetId",  "annotations": {"var_double": "100.5"}}]}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/create?sid=$sessionId&study=$study |500|  Content-Type: application/json |jsonbody.error == 'Missing required variable var_int'|

!3 Get Sample 
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/$sampleId/info?sid=$sessionId|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].id == '$sampleId'|

!3 Get Sample Including Individual
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/$sampleId/info?sid=$sessionId&includeIndividual=true|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].id == '$sampleId2' && jsonbody.response[0].result[0].individual.id == '$individualId'|

!3 Get Individual 
!|Table: Rest Fixture | $baseURL |
| GET | /v1/individuals/$individualId/info?sid=$sessionId|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].id == '$individualId'|

!3 Update Sample Without Version Increment
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "newName" }|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/$sampleId/update?sid=$sessionId&incVersion=false |200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == 'newName'|

!3 Update Sample With Version Increment
!|Table: Rest Fixture | $baseURL |
| setBody | {"name" : "$updatedName" }|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/$sampleId/update?sid=$sessionId&incVersion=true |200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$updatedName' && jsonbody.response[0].result[0].version == '2'|

!3 Update Only Sample Version
!|Table: Rest Fixture | $baseURL |
| setBody | {}|
| setHeader|Content-Type:application/json|
| POST | /v1/samples/$sampleId/update?sid=$sessionId&incVersion=true |200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].version == '3'|

!3 Get Sample Returns Latest Version
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/$sampleId/info?sid=$sessionId|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$updatedName' && jsonbody.response[0].result[0].version == '3'|

!3 Search Sample Returns Latest Version
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/search?sid=$sessionId&name=$updatedName|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result[0].name == '$updatedName' && jsonbody.response[0].result[0].version == '3'|

!3 Get Sample (All Versions)
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/$sampleId/info?sid=$sessionId&allVersions=true|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].result.length == 3|

!3 Get Samples as Groups
!|Table: Rest Fixture | $baseURL |
| GET | /v1/samples/groupBy?sid=$sessionId&study=$study&fields=name%2Csource&limit=5|200|  Content-Type: application/json |jsonbody.error == '' && jsonbody.response[0].numResults > '0' && jsonbody.response[0].result[0]._id.name != ''|

!3 Get Sample ACL
!|Table: Rest Fixture | $baseURL |
{'fraction_non_alphanumeric': 0.2042090423925083, 'fraction_numerical': 0.02869801631255664, 'mean_word_length': 6.478915662650603, 'pattern_counts': {'":': 36, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374961', 'n_tokens_mistral': 3586, 'n_tokens_neox': 3391, 'n_words': 630}