Skip to content

Commit

Permalink
RANGER-3722: Fix Test-case failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavik Patel authored and bhavikpatel9977 committed Nov 27, 2023
1 parent c7573d0 commit 1d5ac09
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -1762,7 +1763,7 @@ public void test49importPoliciesFromFileAllowingOverride() throws Exception {
SearchFilter filter = new SearchFilter();
filter.setParam("serviceType", "value");

File jsonPolicyFile = new File(importPoliceTestFilePath);
File jsonPolicyFile = getFile(importPoliceTestFilePath);
InputStream uploadedInputStream = new FileInputStream(jsonPolicyFile);
FormDataContentDisposition fileDetail = FormDataContentDisposition.name("file")
.fileName(jsonPolicyFile.getName()).size(uploadedInputStream.toString().length()).build();
Expand Down Expand Up @@ -1827,7 +1828,7 @@ public void test50importPoliciesFromFileNotAllowingOverride() throws Exception {
SearchFilter filter = new SearchFilter();
filter.setParam("serviceType", "value");

File jsonPolicyFile = new File(importPoliceTestFilePath);
File jsonPolicyFile = getFile(importPoliceTestFilePath);
InputStream uploadedInputStream = new FileInputStream(jsonPolicyFile);
FormDataContentDisposition fileDetail = FormDataContentDisposition.name("file")
.fileName(jsonPolicyFile.getName()).size(uploadedInputStream.toString().length()).build();
Expand Down Expand Up @@ -1860,6 +1861,14 @@ public void test50importPoliciesFromFileNotAllowingOverride() throws Exception {

}

private File getFile(String testFilePath) throws IOException {
File jsonPolicyFile = new File(testFilePath);
if (jsonPolicyFile.getCanonicalPath().contains("/target/jstest")) {
jsonPolicyFile = new File(jsonPolicyFile.getCanonicalPath().replace("/target/jstest", ""));
}
return jsonPolicyFile;
}

@Test
public void test51getMetricByType() throws Exception {
String type = "usergroup";
Expand Down

0 comments on commit 1d5ac09

Please sign in to comment.