@@ -602,7 +602,7 @@ void testDeleteMultipleAttachmentsReferencesFootnotes() throws IOException {
602602 @ Test
603603 @ Order (13 )
604604 void testUploadMultipleAttachment_RestrictedCharacters () throws IOException {
605- System .out .println ("Test (13) : Restricted characters" );
605+ System .out .println ("Test (13) : Creating attachment with Restricted characters" );
606606
607607 ClassLoader classLoader = getClass ().getClassLoader ();
608608 File file = new File (classLoader .getResource ("abc.pdf" ).getFile ());
@@ -624,9 +624,10 @@ void testUploadMultipleAttachment_RestrictedCharacters() throws IOException {
624624 int renameCount = 0 ;
625625
626626 for (int i = 0 ; i < facet .length ; i ++) {
627+ File renamedFile = new File (file .getParent (), "Sam.//..pdf" );
627628 List <String > createResponse =
628- api .createAttachment_RestrictedCharacter (
629- appUrl , serviceName , entityName , facet [i ], entityID2 , srvpath , postData , file );
629+ api .createAttachment (
630+ appUrl , serviceName , entityName , facet [i ], entityID2 , srvpath , postData , renamedFile );
630631
631632 System .out .println ("Create response for facet[" + i + "]: " + createResponse );
632633
@@ -2013,104 +2014,4 @@ void testUploadNAttachments() throws IOException {
20132014 }
20142015 }
20152016 }
2016-
2017- // @Test
2018- // @Order(23)
2019- // void testUploadNAttachmentsNoSDMRoles() throws IOException {
2020- // System.out.println("Upload attachment without SDM Roles and with assigned role collection");
2021-
2022- // Properties credentialsProperties = Credentials.getCredentials();
2023- // String clientId = credentialsProperties.getProperty("clientID");
2024- // String clientSecret = credentialsProperties.getProperty("clientSecret");
2025- // appUrl = credentialsProperties.getProperty("appUrl");
2026- // authUrl = credentialsProperties.getProperty("authUrl");
2027- // String username2 = credentialsProperties.getProperty("username2");
2028- // String password2 = credentialsProperties.getProperty("password2");
2029-
2030- // String credentials = clientId + ":" + clientSecret;
2031- // String basicAuth =
2032- // "Basic " +
2033- // Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.UTF_8));
2034-
2035- // OkHttpClient client = new OkHttpClient().newBuilder().build();
2036- // MediaType mediaType = MediaType.parse("text/plain");
2037- // RequestBody body = RequestBody.create(mediaType, "");
2038- // Request request =
2039- // new Request.Builder()
2040- // .url(
2041- // authUrl
2042- // + "/oauth/token?grant_type=password&username="
2043- // + username2
2044- // + "&password="
2045- // + password2)
2046- // .method("POST", body)
2047- // .addHeader("Authorization", basicAuth)
2048- // .build();
2049- // Response response = client.newCall(request).execute();
2050- // if (response.code() != 200) {
2051- // System.out.println("Token generation failed. Response code: " + response.code());
2052- // String errorBody = response.body().string();
2053- // System.out.println("Error body: " + errorBody);
2054- // }
2055- // token = new ObjectMapper().readTree(response.body().string()).get("access_token").asText();
2056- // response.close();
2057- // Map<String, String> config = new HashMap<>();
2058- // config.put("Authorization", "Bearer " + token);
2059- // api = new Api(config);
2060-
2061- // ClassLoader classLoader = getClass().getClassLoader();
2062- // File originalFile = new File(classLoader.getResource("sample.exe").getFile());
2063-
2064- // boolean testStatus = false;
2065- // String createResponse =
2066- // api.editEntityDraft(appUrl, serviceName, entityName, srvpath, entityID4);
2067- // System.out.println("response: " + response);
2068-
2069- // if ("Entity in draft mode".equals(response)) {
2070- // for (int i = 1; i <= 5; i++) {
2071- // File tempFile = File.createTempFile("sample_" + i + "_", ".exe");
2072- // Files.copy(originalFile.toPath(), tempFile.toPath(),
2073- // StandardCopyOption.REPLACE_EXISTING);
2074-
2075- // Map<String, Object> postData = new HashMap<>();
2076- // postData.put("up__ID", entityID4);
2077- // postData.put("mimeType", "application/exe");
2078- // postData.put("createdAt", new Date().toString());
2079- // postData.put("createdBy", "test@test.com");
2080- // postData.put("modifiedBy", "test@test.com");
2081-
2082- // List<String> createResponse2 =
2083- // api.createAttachment(
2084- // appUrl, serviceName, entityName, facet[0], entityID4, srvpath, postData,
2085- // tempFile);
2086-
2087- // String resultMessage = createResponse2.get(0);
2088- // System.out.println("Result message for attachment " + i + ": " + resultMessage);
2089-
2090- // if (resultMessage.contains("Only 4 attachments allowed")) {
2091- // String expectedJson =
2092- // "{\"error\":{\"code\":\"500\",\"message\":\"Only 4 attachments allowed.\"}}";
2093- // ObjectMapper objectMapper = new ObjectMapper();
2094- // JsonNode actualJsonNode = objectMapper.readTree(resultMessage);
2095- // JsonNode expectedJsonNode = objectMapper.readTree(expectedJson);
2096- // if (expectedJsonNode.equals(actualJsonNode)) {
2097- // testStatus = true;
2098- // }
2099- // } else {
2100- // testStatus = false;
2101- // }
2102- // tempFile.delete();
2103- // }
2104- // if (!testStatus) {
2105- // fail("5th attachment did not trigger the expected error.");
2106- // }
2107- // String deleteEntityResponse = api.deleteEntity(appUrl, serviceName, entityName, entityID4);
2108- // if (deleteEntityResponse != "Entity Deleted") {
2109- // fail("Could not delete entity");
2110- // } else {
2111- // System.out.println("Successfully deleted the test entity4");
2112- // }
2113- // }
2114- // }
2115-
21162017}
0 commit comments