// Path: src/main/java/ninja/eivind/hotsreplayuploader/utils/StormHandler.java
// @Component
// public class StormHandler {
// 
//     private static final String ACCOUNT_FOLDER_FILTER = "(\\d+[^A-Za-z,.\\-()\\s])";
//     private static final String hotsAccountFilter = "(\\d-Hero-\\d-\\d{1,20})";
// 
//     private File hotsHome;
//     @Autowired
//     private PlatformService platformService;
// 
//     public StormHandler() {
//     }
// 
//     public File getHotSHome() {
//         if (hotsHome == null) {
//             hotsHome = buildHotSHome();
//         }
//         return hotsHome;
//     }
// 
//     /**
//      * Retrieves a {@link List} of {@link File}s, which represent
//      * the replay file directory for a specific {@link Account}.
//      * @return {@link List} of directories or an empty {@link List}
//      */
//     public List<File> getReplayDirectories() {
//         return getAccountDirectories().stream()
//                 .map(StormHandler::getReplayDirectory)
//                 .collect(Collectors.toList());
//     }
// 
//     private static File getReplayDirectory(File dir) {
//         return new File(dir, "Replays" + File.separator + "Multiplayer");
//     }
// 
//     /**
//      * Builds a {@link List} of URIs to the HOTSlogs API, which
//      * can be used to retrieve {@link Player} information.
//      * @return {@link List} of uris or an empty {@link List}
//      */
//     public List<String> getAccountStringUris() {
//         final List<File> accountDirectories = getAccountDirectories();
// 
//         return accountDirectories.stream()
//                 .map(folder -> {
//                     String[] split = folder.getName().replace("-Hero", "").split("-");
//                     StringBuilder accountNameBuilder = new StringBuilder();
//                     for (final String s : split) {
//                         accountNameBuilder.append("/").append(s);
//                     }
// 
//                     return "https://www.hotslogs.com/API/Players" + accountNameBuilder.toString();
//                 }).collect(Collectors.toList());
//     }
// 
//     public String getHotSAccountFilter() {
//         return hotsAccountFilter;
//     }
// 
//     private File buildHotSHome() {
//         String hotsHome = System.getProperty("hots.home");
//         if (hotsHome != null) {
//             return new File(hotsHome);
//         } else {
//             return platformService.getHotSHome();
//         }
//     }
// 
//     private static long maxLastModified(File dir) {
//         File[] files = getReplayDirectory(dir).listFiles();
//         if (files == null || files.length < 1) return Long.MIN_VALUE;
//         return Arrays.stream(files)
//                 .mapToLong(File::lastModified)
//                 .max().orElse(Long.MIN_VALUE);
//     }
// 
//     /**
//      * Retrieves a {@link List} of {@link File}s, each containing files for a specific {@link Account}.
//      * @return {@link List} of directories or an empty {@link List}
//      */
//     private List<File> getAccountDirectories() {
//         final List<File> hotsAccounts = new ArrayList<>();
//         File[] files = getHotSHome().listFiles((dir, name) -> name.matches(ACCOUNT_FOLDER_FILTER));
//         if (files == null) {
//             files = new File[0];
//         }
//         for (final File file : files) {
//             final File[] hotsFolders = file.listFiles((dir, name) -> name.matches(hotsAccountFilter));
//             Arrays.stream(hotsFolders).forEach(hotsAccounts::add);
//         }
// 
//          return hotsAccounts.stream()
//                 .sorted((f1, f2) -> Long.compare(maxLastModified(f2), maxLastModified(f1)))
//                 .collect(Collectors.toList());
//     }
// }


import ninja.eivind.hotsreplayuploader.utils.StormHandler;
import org.junit.Before;
import static org.mockito.Mockito.*;
// Copyright 2015 Eivind Vegsundvåg
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ninja.eivind.hotsreplayuploader.services;



public class UploaderServiceTest {

    private UploaderService uploaderService;
// Path: src/main/java/ninja/eivind/hotsreplayuploader/utils/StormHandler.java
// @Component
// public class StormHandler {
// 
//     private static final String ACCOUNT_FOLDER_FILTER = "(\\d+[^A-Za-z,.\\-()\\s])";
//     private static final String hotsAccountFilter = "(\\d-Hero-\\d-\\d{1,20})";
// 
//     private File hotsHome;
//     @Autowired
//     private PlatformService platformService;
// 
//     public StormHandler() {
//     }
// 
//     public File getHotSHome() {
//         if (hotsHome == null) {
//             hotsHome = buildHotSHome();
//         }
//         return hotsHome;
//     }
// 
//     /**
//      * Retrieves a {@link List} of {@link File}s, which represent
//      * the replay file directory for a specific {@link Account}.
//      * @return {@link List} of directories or an empty {@link List}
//      */
//     public List<File> getReplayDirectories() {
//         return getAccountDirectories().stream()
//                 .map(StormHandler::getReplayDirectory)
//                 .collect(Collectors.toList());
//     }
// 
//     private static File getReplayDirectory(File dir) {
//         return new File(dir, "Replays" + File.separator + "Multiplayer");
//     }
// 
//     /**
//      * Builds a {@link List} of URIs to the HOTSlogs API, which
//      * can be used to retrieve {@link Player} information.
//      * @return {@link List} of uris or an empty {@link List}
//      */
//     public List<String> getAccountStringUris() {
//         final List<File> accountDirectories = getAccountDirectories();
// 
//         return accountDirectories.stream()
//                 .map(folder -> {
//                     String[] split = folder.getName().replace("-Hero", "").split("-");
//                     StringBuilder accountNameBuilder = new StringBuilder();
//                     for (final String s : split) {
//                         accountNameBuilder.append("/").append(s);
//                     }
// 
//                     return "https://www.hotslogs.com/API/Players" + accountNameBuilder.toString();
//                 }).collect(Collectors.toList());
//     }
// 
//     public String getHotSAccountFilter() {
//         return hotsAccountFilter;
//     }
// 
//     private File buildHotSHome() {
//         String hotsHome = System.getProperty("hots.home");
//         if (hotsHome != null) {
//             return new File(hotsHome);
//         } else {
//             return platformService.getHotSHome();
//         }
//     }
// 
//     private static long maxLastModified(File dir) {
//         File[] files = getReplayDirectory(dir).listFiles();
//         if (files == null || files.length < 1) return Long.MIN_VALUE;
//         return Arrays.stream(files)
//                 .mapToLong(File::lastModified)
//                 .max().orElse(Long.MIN_VALUE);
//     }
// 
//     /**
//      * Retrieves a {@link List} of {@link File}s, each containing files for a specific {@link Account}.
//      * @return {@link List} of directories or an empty {@link List}
//      */
//     private List<File> getAccountDirectories() {
//         final List<File> hotsAccounts = new ArrayList<>();
//         File[] files = getHotSHome().listFiles((dir, name) -> name.matches(ACCOUNT_FOLDER_FILTER));
//         if (files == null) {
//             files = new File[0];
//         }
//         for (final File file : files) {
//             final File[] hotsFolders = file.listFiles((dir, name) -> name.matches(hotsAccountFilter));
//             Arrays.stream(hotsFolders).forEach(hotsAccounts::add);
//         }
// 
//          return hotsAccounts.stream()
//                 .sorted((f1, f2) -> Long.compare(maxLastModified(f2), maxLastModified(f1)))
//                 .collect(Collectors.toList());
//     }
// }


// Path: src/test/java/ninja/eivind/hotsreplayuploader/services/UploaderServiceTest.java
import ninja.eivind.hotsreplayuploader.utils.StormHandler;
import org.junit.Before;
import static org.mockito.Mockito.*;

// Copyright 2015 Eivind Vegsundvåg
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ninja.eivind.hotsreplayuploader.services;



public class UploaderServiceTest {

    private UploaderService uploaderService;
    private StormHandler stormHandlerMock;