Skip to content

Commit

Permalink
updated quant test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
vamshimupparaju committed Sep 1, 2023
1 parent 6cfcd45 commit e6c9a72
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 2 additions & 0 deletions tests/src/test/java/Api/CommonParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public class CommonParameters {
public static QuantScreeningExpressionUniverse.UniverseTypeEnum QuantUniverseType = QuantScreeningExpressionUniverse.UniverseTypeEnum.EQUITY;
public static String QuantSecurityExpr = "TICKER";
public static String QuantScreeningExpr = "P_PRICE";

public static String QuantInvalidScreeningExpr = "FF_MKT_VAL(AN_R,0,RP,USD)";
public static String QuantScreeningName = "Price (SCR)";
public static String QuantFqlExpr = "P_PRICE";
public static String QuantFqlName = "Price (SCR)";
Expand Down
38 changes: 27 additions & 11 deletions tests/src/test/java/Api/QuantInteractiveEngineTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void before() {
apiInstance = new QuantCalculationsApi(apiClient);
}

private QuantCalculationParameters enginesApi_createUnitCalculation() throws ApiException {
private QuantCalculationParameters enginesApi_createUnitCalculation(boolean expectedWarningsInResponse) throws ApiException {

QuantCalculationParameters quantItem = new QuantCalculationParameters();

QuantFdsDate fdsDate = new QuantFdsDate();
Expand All @@ -56,7 +57,9 @@ private QuantCalculationParameters enginesApi_createUnitCalculation() throws Api
OneOfQuantUniverse universe = new OneOfQuantUniverse(screeningExpressionUniverse);

QuantScreeningExpression screeningExpression = new QuantScreeningExpression();
screeningExpression.expr(CommonParameters.QuantScreeningExpr);

String expr = expectedWarningsInResponse ? CommonParameters.QuantInvalidScreeningExpr : CommonParameters.QuantScreeningExpr;
screeningExpression.expr(expr);
screeningExpression.name(CommonParameters.QuantScreeningName);
screeningExpression.setSource(QuantScreeningExpression.SourceEnum.SCREENINGEXPRESSION);

Expand All @@ -75,7 +78,7 @@ private QuantCalculationParameters enginesApi_createUnitCalculation() throws Api

return quantItem;
}

private ApiResponse<File> GetCalculationResult(String[] location) throws ApiException {
ApiResponse<File> resultResponse = null;
try {
Expand All @@ -97,18 +100,18 @@ private QuantCalculationParameters enginesApi_isArrayReturnType_createUnitCalcul
fdsDate.setFrequency(CommonParameters.QuantFrequency);
fdsDate.setCalendar(CommonParameters.QuantCalender);
fdsDate.setSource(QuantFdsDate.SourceEnum.FDSDATE);

OneOfQuantDates dates = new OneOfQuantDates(fdsDate);

List<String> identifiers = new ArrayList<String>();
identifiers.add("03748R74");
identifiers.add("S8112735");
QuantIdentifierUniverse identifierUniverse = new QuantIdentifierUniverse();

QuantIdentifierUniverse identifierUniverse = new QuantIdentifierUniverse();
identifierUniverse.setUniverseType(QuantIdentifierUniverse.UniverseTypeEnum.EQUITY);
identifierUniverse.setIdentifiers(identifiers);
identifierUniverse.setSource(QuantIdentifierUniverse.SourceEnum.IDENTIFIERUNIVERSE);

OneOfQuantUniverse universe = new OneOfQuantUniverse(identifierUniverse);

QuantScreeningExpression screeningExpression = new QuantScreeningExpression();
Expand All @@ -120,13 +123,13 @@ private QuantCalculationParameters enginesApi_isArrayReturnType_createUnitCalcul
fqlExpression.setExpr(CommonParameters.QuantFqlExpr);
fqlExpression.setName(CommonParameters.QuantFqlName);
fqlExpression.setSource(QuantFqlExpression.SourceEnum.FQLEXPRESSION);

QuantFqlExpression fqlExpression_isArrayReturnType = new QuantFqlExpression();
fqlExpression_isArrayReturnType.setExpr(CommonParameters.QuantFqlExpr_Price_Range);
fqlExpression_isArrayReturnType.setName(CommonParameters.QuantFqlName_Price_Label);
fqlExpression_isArrayReturnType.setIsArrayReturnType(true);
fqlExpression_isArrayReturnType.setSource(QuantFqlExpression.SourceEnum.FQLEXPRESSION);

List<OneOfQuantFormulas> formulas = new ArrayList<OneOfQuantFormulas>();
formulas.add(new OneOfQuantFormulas(screeningExpression));
formulas.add(new OneOfQuantFormulas(fqlExpression));
Expand Down Expand Up @@ -187,6 +190,9 @@ private void ProcessCalculations(QuantCalculationParameters calculationUnit) thr
}
} while(resultStatusResponse.getStatusCode() == 202);
for(CalculationUnitStatus unitStatus : resultStatus.getData().getUnits().values()) {
if(unitStatus.getWarnings()!=null){
Assert.assertTrue("unitStatus with warnings should have a reason", (!unitStatus.getWarnings().get(0).isEmpty()));
}
String[] location = unitStatus.getResult().split("/");
resultResponse = GetCalculationResult(location);
headers = resultResponse.getHeaders();
Expand All @@ -211,7 +217,17 @@ public void enginesApi_isArrayReturnType_GetCalculationSuccess() throws ApiExcep
@Test
public void enginesApiGetCalculationSuccess() throws ApiException, JsonProcessingException, InterruptedException {
try {
QuantCalculationParameters calculationUnit = enginesApi_createUnitCalculation();
QuantCalculationParameters calculationUnit = enginesApi_createUnitCalculation(false);
ProcessCalculations(calculationUnit);
} catch (ApiException e) {
CommonFunctions.handleException("EngineApi#runCalculation", e);
}
}

@Test
public void enginesApiGetCalculationSuccessWithwarnings() throws ApiException, JsonProcessingException, InterruptedException {
try {
QuantCalculationParameters calculationUnit = enginesApi_createUnitCalculation(true);
ProcessCalculations(calculationUnit);
} catch (ApiException e) {
CommonFunctions.handleException("EngineApi#runCalculation", e);
Expand Down

0 comments on commit e6c9a72

Please sign in to comment.