test_class.file: org.eclipse.winery.tools.copybaragenerator/src/test/java/org/eclipse/winery/tools/copybaragenerator/CopybaraGeneratorTest.java
test_class.identifier: CopybaraGeneratorTest
test_class.superclass: extends TestWithGitBackedRepository
test_case.body: @Test
      public void generatedOriginFilesConfigHasCorrectStrings() throws Exception {
          // we use the commit 4b218e6 instead of origin/plain, because the number of definitions changes fast
          this.setRevisionTo("4b218e6");
          CopybaraGenerator copybaraGenerator = new CopybaraGenerator();
          String config = copybaraGenerator.generateOriginFilesConfig();
          assertEquals("origin_files = glob([\"README.md\", \"LICENSE\", \"artifacttemplates/http%3A%2F%2Fplain.winery.opentosca.org%2Fartifacttemplates/ArtifactTemplateWithFilesAndSources-ArtifactTypeWithoutProperties/**\",\n" +
              "        \"artifacttemplates/http%3A%2F%2Fplain.winery.opentosca.org%2Fartifacttemplates/ArtifactTemplateWithoutAnyFiles-ArtifactTypeWithoutProperties/**\"]),", config);
      }
test_case.class_method_signature: CopybaraGeneratorTest.generatedOriginFilesConfigHasCorrectStrings()
test_case.full_signature: @Test public void generatedOriginFilesConfigHasCorrectStrings()
test_case.identifier: generatedOriginFilesConfigHasCorrectStrings
test_case.invocations: setRevisionTo generateOriginFilesConfig assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void generatedOriginFilesConfigHasCorrectStrings()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(CopybaraGenerator.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(CopybaraGenerator.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: repository
focal_class.modifier: private final
focal_class.original_string: private final IRepository repository;
focal_class.type: IRepository
focal_class.var_name: repository
focal_class.file: org.eclipse.winery.tools.copybaragenerator/src/main/java/org/eclipse/winery/tools/copybaragenerator/CopybaraGenerator.java
focal_class.identifier: CopybaraGenerator
focal_class.class_method_signature: CopybaraGenerator.CopybaraGenerator()
focal_class.full_signature: public  CopybaraGenerator()
focal_class.identifier: CopybaraGenerator
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  CopybaraGenerator()
focal_class.class_method_signature: CopybaraGenerator.CopybaraGenerator(IRepository repository)
focal_class.full_signature: public  CopybaraGenerator(IRepository repository)
focal_class.identifier: CopybaraGenerator
focal_class.modifiers: public
focal_class.parameters: (IRepository repository)
focal_class.signature:  CopybaraGenerator(IRepository repository)
focal_class.class_method_signature: CopybaraGenerator.generateOriginFilesConfig()
focal_class.full_signature: public String generateOriginFilesConfig()
focal_class.identifier: generateOriginFilesConfig
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String generateOriginFilesConfig()
focal_class.class_method_signature: CopybaraGenerator.generateCopybaraConfigFile()
focal_class.full_signature: public String generateCopybaraConfigFile()
focal_class.identifier: generateCopybaraConfigFile
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String generateCopybaraConfigFile()
focal_class.class_method_signature: CopybaraGenerator.generateCopybaraConfigFile(Path targetFile)
focal_class.full_signature: public void generateCopybaraConfigFile(Path targetFile)
focal_class.identifier: generateCopybaraConfigFile
focal_class.modifiers: public
focal_class.parameters: (Path targetFile)
focal_class.return: void
focal_class.signature: void generateCopybaraConfigFile(Path targetFile)
focal_method.body: public String generateOriginFilesConfig() {
          SortedSet<DefinitionsChildId> allDefinitionsChildIds = repository.getAllDefinitionsChildIds();
          return allDefinitionsChildIds.stream()
              .filter(id -> {
                  RepositoryFileReference repositoryFileReference = new RepositoryFileReference(id, Constants.LICENSE_FILE_NAME);
                  if (!repository.exists(repositoryFileReference)) {
                      return false;
                  }
                  try (InputStream inputStream = repository.newInputStream(repositoryFileReference)) {
                      // we put the whole license file text into a string and check if it starts with "Apache License" after
                      // trimming it
                      final String licenceString = "Apache License";
                      String fileAsString = IOUtils.toString(inputStream);
  
                      return fileAsString.trim().startsWith(licenceString);
                  } catch (IOException e) {
                      LOGGER.error("Could not create input stream for {}", repositoryFileReference.toString(), e);
                      return false;
                  }
              })
              .map(id -> BackendUtils.getPathInsideRepo(id))
              .collect(Collectors.joining("**\",\n        \"", "origin_files = glob([\"README.md\", \"LICENSE\", \"", "**\"]),"));
      }
focal_method.class_method_signature: CopybaraGenerator.generateOriginFilesConfig()
focal_method.full_signature: public String generateOriginFilesConfig()
focal_method.identifier: generateOriginFilesConfig
focal_method.invocations: getAllDefinitionsChildIds collect map filter stream exists newInputStream toString startsWith trim error toString getPathInsideRepo joining
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: String
focal_method.signature: String generateOriginFilesConfig()