private Test mapTest(
     PuzzleTestDto puzzleTest, Runner runner, Map<String, ByteArrayOutputStream> testFiles)
     throws IOException {
   Test test = new Test();
   test.setIndex(Integer.parseInt(puzzleTest.getIndex()));
   test.setRunner(runner);
   test = testRepository.save(test);
   String inputFileName = test.getId() + "/" + puzzleTest.getIndex() + ".txt";
   if (testFiles == null) {
     storage.uploadPublic(
         testsBucket,
         inputFileName,
         new ByteArrayInputStream(puzzleTest.getData().getBytes()),
         "text/plain");
   } else {
     storage.uploadPublic(
         testsBucket,
         inputFileName,
         new ByteArrayInputStream(testFiles.get(puzzleTest.getData()).toByteArray()),
         "text/plain");
   }
   storage.upload(
       testsBucket,
       test.getId() + "/output.txt",
       new ByteArrayInputStream(puzzleTest.getSolution().getBytes()),
       "text/plain");
   Map<String, String> testParams = new HashMap<>();
   testParams.put("test", testsBucket + "/" + test.getId() + "/output.txt");
   testParams.put("stdin", testsBucket + "/" + inputFileName);
   test.setParams(testParams);
   test = testRepository.save(test);
   test.setRunner(runner);
   return test;
 }
 private Task mapTask(
     PuzzleDto puzzle,
     ChallengeTemplate challengeTemplate,
     Organization organization,
     Map<String, ByteArrayOutputStream> files,
     Duration gameDuration,
     Runner runner,
     Endpoint endpoint,
     Set<Language> languages)
     throws IOException {
   Task task = new Task();
   task.setCanonicalName(
       fixCanonicalName(challengeTemplate.getCanonicalName() + "-" + puzzle.getCanonicalName()));
   task.setName(puzzle.getCanonicalName());
   task.setEndpoint(endpoint);
   task.setDescription(puzzle.getCanonicalName());
   task.setInstructions(
       storage.uploadPublic(
           instructionsBucket,
           instructionsFileName(challengeTemplate, puzzle.getInstructionsFile()),
           new ByteArrayInputStream(files.get(puzzle.getInstructionsFile()).toByteArray()),
           "application/pdf"));
   task.setDuration(gameDuration);
   task.setRunner(runner);
   task.setLanguages(languages);
   task.setOrganization(organization);
   return task;
 }