Test for yang file archive limitation
[cps.git] / cps-rest / src / main / java / org / onap / cps / rest / utils / MultipartFileUtil.java
index 534077c..3e01f6e 100644 (file)
@@ -2,6 +2,7 @@
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Pantheon.tech
  *  Modifications Copyright (C) 2021 Bell Canada.
+ *  Modifications Copyright (C) 2023 Nordix Foundation.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -127,16 +128,17 @@ public class MultipartFileUtil {
     }
 
     private static String extractYangResourceContent(final ZipInputStream zipInputStream,
-        final ZipFileSizeValidator zipFileSizeValidator) throws IOException {
+                                                     final ZipFileSizeValidator zipFileSizeValidator)
+        throws IOException {
         try (final var byteArrayOutputStream = new ByteArrayOutputStream()) {
             var totalSizeEntry = 0;
             int numberOfBytesRead;
             final var buffer = new byte[READ_BUFFER_SIZE];
-            zipFileSizeValidator.incrementTotalEntryInArchive();
+            zipFileSizeValidator.incrementTotalYangFileEntryCountInArchive();
             while ((numberOfBytesRead = zipInputStream.read(buffer, 0, READ_BUFFER_SIZE)) > 0) {
                 byteArrayOutputStream.write(buffer, 0, numberOfBytesRead);
                 totalSizeEntry += numberOfBytesRead;
-                zipFileSizeValidator.updateTotalSizeArchive(numberOfBytesRead);
+                zipFileSizeValidator.updateTotalUncompressedSizeOfYangFilesInArchive(numberOfBytesRead);
                 zipFileSizeValidator.validateCompresssionRatio(totalSizeEntry);
             }
             return byteArrayOutputStream.toString(StandardCharsets.UTF_8);