Skip to content
Snippets Groups Projects
Commit f3b8426e authored by Lars Johansson's avatar Lars Johansson
Browse files

Refactor integration test support classes

parent cc955991
No related branches found
Tags 1.0.15
No related merge requests found
Pipeline #119609 passed
......@@ -316,7 +316,6 @@ public class ITUtilNameElement {
public static void assertExists(String name, Boolean expected) {
assertExists(name, expected, null);
}
/**
* Utility method to check if name exists.
*
......@@ -394,7 +393,7 @@ public class ITUtilNameElement {
* @param responseCode response code
*/
public static void assertValidate(String json, NameChoice nameChoice, int responseCode) {
assertValidate(json, nameChoice, responseCode, Boolean.FALSE, Boolean.FALSE);
assertValidate(AuthorizationChoice.NONE, json, nameChoice, responseCode, Boolean.FALSE, Boolean.FALSE);
}
/**
* Utility method to (try to) validate a name element from given json and assert expected response.
......@@ -408,12 +407,27 @@ public class ITUtilNameElement {
* @param expectedMessageEmpty expected message empty
*/
public static void assertValidate(String json, NameChoice nameChoice, int responseCode, Boolean expected, Boolean expectedMessageEmpty) {
assertValidate(AuthorizationChoice.NONE, json, nameChoice, responseCode, expected, expectedMessageEmpty);
}
/**
* Utility method to (try to) validate a name element from given json and assert expected response.
* Method expected to NOT succeed to validate
* but instead assert response code (possibly also a non-empty message).
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param json json
* @param nameChoice name choice
* @param responseCode response code
* @param expected expected
* @param expectedMessageEmpty expected message empty
*/
public static void assertValidate(AuthorizationChoice authorizationChoice, String json, NameChoice nameChoice, int responseCode, Boolean expected, Boolean expectedMessageEmpty) {
String validatePath = getValidatePath(nameChoice);
try {
String[] response = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, validatePath, json));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.NAMES, validatePath, json));
ITUtil.assertResponseLength2Code(response, responseCode);
if (response[1] != null) {
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected, expectedMessageEmpty);
......@@ -439,9 +453,8 @@ public class ITUtilNameElement {
*/
public static void assertValidate(NameElementCommand nameElement, NameChoice nameChoice, String index, Boolean expected) {
nameElement.setIndex(index);
assertValidate(nameElement, nameChoice, expected);
assertValidate(AuthorizationChoice.NONE, new NameElementCommand[] {nameElement}, nameChoice, expected);
}
/**
* Utility method to validate name element and assert expected response.
*
......@@ -450,7 +463,7 @@ public class ITUtilNameElement {
* @param expected expected response
*/
public static void assertValidate(NameElementCommand nameElement, NameChoice nameChoice, Boolean expected) {
assertValidate(new NameElementCommand[] {nameElement}, nameChoice, expected);
assertValidate(AuthorizationChoice.NONE, new NameElementCommand[] {nameElement}, nameChoice, expected);
}
/**
* Utility method to validate name elements and assert expected response.
......@@ -460,12 +473,23 @@ public class ITUtilNameElement {
* @param expected expected response
*/
public static void assertValidate(NameElementCommand[] nameElements, NameChoice nameChoice, Boolean expected) {
assertValidate(AuthorizationChoice.NONE, nameElements, nameChoice, expected);
}
/**
* Utility method to validate name elements and assert expected response.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param nameElements name elements
* @param nameChoice name choice
* @param expected expected response
*/
public static void assertValidate(AuthorizationChoice authorizationChoice, NameElementCommand[] nameElements, NameChoice nameChoice, Boolean expected) {
String path = getValidatePath(nameChoice);
try {
String[] response = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, path, object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.NAMES, path, object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected);
} catch (IOException e) {
......@@ -513,9 +537,8 @@ public class ITUtilNameElement {
* @throws JsonProcessingException
*/
public static void assertCreate(NameElementCommand nameElement, int responseCode) throws JsonProcessingException {
assertCreate(object2Json(new NameElementCommand[] {nameElement}), responseCode);
assertCreate(AuthorizationChoice.NONE, object2Json(new NameElementCommand[] {nameElement}), responseCode);
}
/**
* Utility method to (try to) create a name element from given json and assert result response code.
* Method expected to NOT succeed to create a name element
......@@ -525,8 +548,20 @@ public class ITUtilNameElement {
* @param responseCode response code
*/
public static void assertCreate(String json, int responseCode) {
assertCreate(AuthorizationChoice.NONE, json, responseCode);
}
/**
* Utility method to (try to) create a name element from given json and assert result response code.
* Method expected to NOT succeed to create a name element
* but instead assert response code (possibly also a non-empty message).
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param json json
* @param responseCode response code
*/
public static void assertCreate(AuthorizationChoice authorizationChoice, String json, int responseCode) {
try {
String[] response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", json));
String[] response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(authorizationChoice, EndpointChoice.NAMES, "", json));
ITUtil.assertResponseLength2Code(response, responseCode);
// ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class));
} catch (IOException e) {
......@@ -547,7 +582,7 @@ public class ITUtilNameElement {
* @return created name element
*/
public static NameElement assertCreate(NameElementCommand nameElement) {
return assertCreate(new NameElementCommand[] {nameElement})[0];
return assertCreate(AuthorizationChoice.NONE, new NameElementCommand[] {nameElement})[0];
}
/**
* Utility method to create name elements and assert result.
......@@ -556,17 +591,27 @@ public class ITUtilNameElement {
* @return created name element
*/
public static NameElement[] assertCreate(NameElementCommand[] nameElements) {
return assertCreate(AuthorizationChoice.NONE, nameElements);
}
/**
* Utility method to create name elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param nameElements name elements
* @return created name element
*/
public static NameElement[] assertCreate(AuthorizationChoice authorizationChoice, NameElementCommand[] nameElements) {
String path = getValidatePath(NameChoice.CREATE);
try {
String[] response = null;
NameElement[] createdNameElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, path, object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.NAMES, path, object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(authorizationChoice, EndpointChoice.NAMES, "", object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_CREATED);
createdNameElements = mapper.readValue(response[1], NameElement[].class);
......@@ -599,7 +644,7 @@ public class ITUtilNameElement {
* @return updated name element
*/
public static NameElement assertUpdate(NameElementCommand nameElement) {
return assertUpdate(new NameElementCommand[] {nameElement})[0];
return assertUpdate(AuthorizationChoice.NONE, new NameElementCommand[] {nameElement})[0];
}
/**
* Utility method to update name elements and assert result.
......@@ -608,17 +653,27 @@ public class ITUtilNameElement {
* @return updated name element
*/
public static NameElement[] assertUpdate(NameElementCommand[] nameElements) {
return assertUpdate(AuthorizationChoice.NONE, nameElements);
}
/**
* Utility method to update name elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param nameElements name elements
* @return updated name element
*/
public static NameElement[] assertUpdate(AuthorizationChoice authorizationChoice, NameElementCommand[] nameElements) {
String path = getValidatePath(NameChoice.UPDATE);
try {
String[] response = null;
NameElement[] updatedNameElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, path, object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.NAMES, path, object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPutPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlPutPathJson(authorizationChoice, EndpointChoice.NAMES, "", object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
updatedNameElements = mapper.readValue(response[1], NameElement[].class);
......@@ -648,7 +703,7 @@ public class ITUtilNameElement {
* @return deleted name element
*/
public static NameElement assertDelete(NameElementCommand nameElement) {
return assertDelete(new NameElementCommand[] {nameElement})[0];
return assertDelete(AuthorizationChoice.NONE, new NameElementCommand[] {nameElement})[0];
}
/**
* Utility method to delete name elements and assert result.
......@@ -657,17 +712,27 @@ public class ITUtilNameElement {
* @return deleted name element
*/
public static NameElement[] assertDelete(NameElementCommand[] nameElements) {
return assertDelete(AuthorizationChoice.NONE, nameElements);
}
/**
* Utility method to delete name elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param nameElements name elements
* @return deleted name element
*/
public static NameElement[] assertDelete(AuthorizationChoice authorizationChoice, NameElementCommand[] nameElements) {
String path = getValidatePath(NameChoice.DELETE);
try {
String[] response = null;
NameElement[] deletedNameElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, path, object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.NAMES, path, object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlDeletePathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", object2Json(nameElements)));
response = ITUtil.runShellCommand(ITUtil.curlDeletePathJson(authorizationChoice, EndpointChoice.NAMES, "", object2Json(nameElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
deletedNameElements = mapper.readValue(response[1], NameElement[].class);
......
......@@ -319,7 +319,6 @@ public class ITUtilStructureElement {
public static void assertExists(Type type, String mnemonicpath, Boolean expected) {
assertExists(type, mnemonicpath, expected, null);
}
/**
* Utility method to check if structure exists.
*
......@@ -380,10 +379,23 @@ public class ITUtilStructureElement {
* @param responseCode response code
*/
public static void assertValidate(String json, StructureChoice structureChoice, int responseCode) {
assertValidate(AuthorizationChoice.NONE, json, structureChoice, responseCode);
}
/**
* Utility method to (try to) validate a structure element from given json and assert expected response.
* Method expected to NOT succeed to validate
* but instead assert response code (possibly also a non-empty message).
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param json json
* @param structureChoice structure choice
* @param responseCode response code
*/
public static void assertValidate(AuthorizationChoice authorizationChoice, String json, StructureChoice structureChoice, int responseCode) {
String validatePath = getValidatePath(structureChoice);
try {
String[] response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, validatePath, json));
String[] response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, validatePath, json));
ITUtil.assertResponseLength2Code(response, responseCode);
} catch (IOException e) {
fail();
......@@ -404,7 +416,7 @@ public class ITUtilStructureElement {
* @param expected expected response
*/
public static void assertValidate(StructureElementCommand structureElement, StructureChoice structureChoice, Boolean expected) {
assertValidate(new StructureElementCommand[] {structureElement}, structureChoice, expected);
assertValidate(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement}, structureChoice, expected);
}
/**
* Utility method to validate structure elements and assert expected response.
......@@ -414,12 +426,23 @@ public class ITUtilStructureElement {
* @param expected expected response
*/
public static void assertValidate(StructureElementCommand[] structureElements, StructureChoice structureChoice, Boolean expected) {
assertValidate(AuthorizationChoice.NONE, structureElements, structureChoice, expected);
}
/**
* Utility method to validate structure elements and assert expected response.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @param structureChoice structure choice
* @param expected expected response
*/
public static void assertValidate(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements, StructureChoice structureChoice, Boolean expected) {
String path = getValidatePath(structureChoice);
try {
String[] response = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected);
} catch (IOException e) {
......@@ -476,9 +499,8 @@ public class ITUtilStructureElement {
* @throws JsonProcessingException
*/
public static void assertCreate(StructureElementCommand structureElement, int responseCode) throws JsonProcessingException {
assertCreate(object2Json(new StructureElementCommand[] {structureElement}), responseCode);
assertCreate(AuthorizationChoice.NONE, object2Json(new StructureElementCommand[] {structureElement}), responseCode);
}
/**
* Utility method to (try to) create a structure element from given json and assert result response code.
* Method expected to NOT succeed to create a structure element
......@@ -488,8 +510,20 @@ public class ITUtilStructureElement {
* @param responseCode response code
*/
public static void assertCreate(String json, int responseCode) {
assertCreate(AuthorizationChoice.NONE, json, responseCode);
}
/**
* Utility method to (try to) create a structure element from given json and assert result response code.
* Method expected to NOT succeed to create a structure element
* but instead assert response code (possibly also a non-empty message).
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param json json
* @param responseCode response code
*/
public static void assertCreate(AuthorizationChoice authorizationChoice, String json, int responseCode) {
try {
String[] response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", json));
String[] response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(authorizationChoice, EndpointChoice.STRUCTURES, "", json));
ITUtil.assertResponseLength2Code(response, responseCode);
// ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class));
} catch (IOException e) {
......@@ -510,7 +544,7 @@ public class ITUtilStructureElement {
* @return created structure element
*/
public static StructureElement assertCreate(StructureElementCommand structureElement) {
return assertCreate(new StructureElementCommand[] {structureElement})[0];
return assertCreate(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement})[0];
}
/**
* Utility method to create structure elements and assert result.
......@@ -519,17 +553,27 @@ public class ITUtilStructureElement {
* @return created structure element
*/
public static StructureElement[] assertCreate(StructureElementCommand[] structureElements) {
return assertCreate(AuthorizationChoice.NONE, structureElements);
}
/**
* Utility method to create structure elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @return created structure element
*/
public static StructureElement[] assertCreate(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements) {
String path = getValidatePath(StructureChoice.CREATE);
try {
String[] response = null;
StructureElement[] createdStructureElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(authorizationChoice, EndpointChoice.STRUCTURES, "", object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_CREATED);
createdStructureElements = mapper.readValue(response[1], StructureElement[].class);
......@@ -563,7 +607,7 @@ public class ITUtilStructureElement {
* @return updated structure element
*/
public static StructureElement assertUpdate(StructureElementCommand structureElement) {
return assertUpdate(new StructureElementCommand[] {structureElement})[0];
return assertUpdate(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement})[0];
}
/**
* Utility method to update structure elements and assert result.
......@@ -572,17 +616,27 @@ public class ITUtilStructureElement {
* @return updated structure element
*/
public static StructureElement[] assertUpdate(StructureElementCommand[] structureElements) {
return assertUpdate(AuthorizationChoice.NONE, structureElements);
}
/**
* Utility method to update structure elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @return updated structure element
*/
public static StructureElement[] assertUpdate(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements) {
String path = getValidatePath(StructureChoice.UPDATE);
try {
String[] response = null;
StructureElement[] updatedStructureElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPutPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlPutPathJson(authorizationChoice, EndpointChoice.STRUCTURES, "", object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
updatedStructureElements = mapper.readValue(response[1], StructureElement[].class);
......@@ -613,7 +667,7 @@ public class ITUtilStructureElement {
* @return deleted structure element
*/
public static StructureElement assertDelete(StructureElementCommand structureElement) {
return assertDelete(new StructureElementCommand[] {structureElement})[0];
return assertDelete(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement})[0];
}
/**
* Utility method to delete structure elements and assert result.
......@@ -622,17 +676,27 @@ public class ITUtilStructureElement {
* @return deleted structure element
*/
public static StructureElement[] assertDelete(StructureElementCommand[] structureElements) {
return assertDelete(AuthorizationChoice.NONE, structureElements);
}
/**
* Utility method to delete structure elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @return deleted structure element
*/
public static StructureElement[] assertDelete(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements) {
String path = getValidatePath(StructureChoice.DELETE);
try {
String[] response = null;
StructureElement[] deletedStructureElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlDeletePathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlDeletePathJson(authorizationChoice, EndpointChoice.STRUCTURES, "", object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
deletedStructureElements = mapper.readValue(response[1], StructureElement[].class);
......@@ -663,7 +727,7 @@ public class ITUtilStructureElement {
* @return approved structure element
*/
public static StructureElement assertApprove(StructureElementCommand structureElement) {
return assertApprove(new StructureElementCommand[] {structureElement})[0];
return assertApprove(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement})[0];
}
/**
* Utility method to approve structure elements and assert result.
......@@ -672,17 +736,27 @@ public class ITUtilStructureElement {
* @return approved structure element
*/
public static StructureElement[] assertApprove(StructureElementCommand[] structureElements) {
return assertApprove(AuthorizationChoice.NONE, structureElements);
}
/**
* Utility method to approve structure elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @return approved structure element
*/
public static StructureElement[] assertApprove(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements) {
String path = getValidatePath(StructureChoice.APPROVE);
try {
String[] response = null;
StructureElement[] approvedStructureElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPatchPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/approve", object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlPatchPathJson(authorizationChoice, EndpointChoice.STRUCTURES, "/approve", object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
approvedStructureElements = mapper.readValue(response[1], StructureElement[].class);
......@@ -713,7 +787,7 @@ public class ITUtilStructureElement {
* @return cancelled structure element
*/
public static StructureElement assertCancel(StructureElementCommand structureElement) {
return assertCancel(new StructureElementCommand[] {structureElement})[0];
return assertCancel(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement})[0];
}
/**
* Utility method to cancel structure elements and assert result.
......@@ -722,17 +796,27 @@ public class ITUtilStructureElement {
* @return cancelled structure element
*/
public static StructureElement[] assertCancel(StructureElementCommand[] structureElements) {
return assertCancel(AuthorizationChoice.NONE, structureElements);
}
/**
* Utility method to cancel structure elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @return cancelled structure element
*/
public static StructureElement[] assertCancel(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements) {
String path = getValidatePath(StructureChoice.CANCEL);
try {
String[] response = null;
StructureElement[] cancelledStructureElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPatchPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/cancel", object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlPatchPathJson(authorizationChoice, EndpointChoice.STRUCTURES, "/cancel", object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
cancelledStructureElements = mapper.readValue(response[1], StructureElement[].class);
......@@ -763,7 +847,7 @@ public class ITUtilStructureElement {
* @return rejected structure element
*/
public static StructureElement assertReject(StructureElementCommand structureElement) {
return assertReject(new StructureElementCommand[] {structureElement})[0];
return assertReject(AuthorizationChoice.NONE, new StructureElementCommand[] {structureElement})[0];
}
/**
* Utility method to reject structure elements and assert result.
......@@ -772,17 +856,27 @@ public class ITUtilStructureElement {
* @return rejected structure element
*/
public static StructureElement[] assertReject(StructureElementCommand[] structureElements) {
return assertReject(AuthorizationChoice.NONE, structureElements);
}
/**
* Utility method to reject structure elements and assert result.
*
* @param authorizationChoice authorization choice (none, user, admin)
* @param structureElements structure elements
* @return rejected structure element
*/
public static StructureElement[] assertReject(AuthorizationChoice authorizationChoice, StructureElementCommand[] structureElements) {
String path = getValidatePath(StructureChoice.REJECT);
try {
String[] response = null;
StructureElement[] rejectedStructureElements = null;
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(authorizationChoice, EndpointChoice.STRUCTURES, path, object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.TRUE);
response = ITUtil.runShellCommand(ITUtil.curlPatchPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/reject", object2Json(structureElements)));
response = ITUtil.runShellCommand(ITUtil.curlPatchPathJson(authorizationChoice, EndpointChoice.STRUCTURES, "/reject", object2Json(structureElements)));
ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK);
rejectedStructureElements = mapper.readValue(response[1], StructureElement[].class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment