<commit_before>package org.carlspring.strongbox.cron.jobs;

import org.carlspring.strongbox.artifact.coordinates.NugetArtifactCoordinates;
import org.carlspring.strongbox.config.NugetLayoutProviderCronTasksTestConfig;
import org.carlspring.strongbox.providers.io.RepositoryFiles;
import org.carlspring.strongbox.providers.io.RepositoryPath;
import org.carlspring.strongbox.providers.io.RootRepositoryPath;
import org.carlspring.strongbox.storage.repository.Repository;
import org.carlspring.strongbox.storage.repository.RepositoryPolicyEnum;
import org.carlspring.strongbox.testing.artifact.ArtifactManagementTestExecutionListener;
import org.carlspring.strongbox.testing.artifact.NugetTestArtifact;
import org.carlspring.strongbox.testing.repository.NugetRepository;
import org.carlspring.strongbox.testing.storage.repository.RepositoryManagementTestExecutionListener;
import org.carlspring.strongbox.util.ThrowingConsumer;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.parallel.Execution;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import static java.nio.file.Files.deleteIfExists;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;

/**
 * @author <NAME>.
 * @author <NAME>
 */
@ContextConfiguration(classes = NugetLayoutProviderCronTasksTestConfig.class)
@SpringBootTest
@ActiveProfiles(profiles = "test")
@Execution(CONCURRENT)
public class RegenerateNugetChecksumCronJobTestIT
        extends BaseCronJobWithNugetIndexingTestCase
{
    private static final String STORAGE1 = "storage-nuget-rnccj";

    private static final String REPOSITORY_RELEASES_TRNAC = "rnccj-releases-trnac";

    private static final String REPOSITORY_RELEASES_TRNCIS = "rnccj-releases-trncis";

    private static final String REPOSITORY_RELEASES_TRNCISS = "rnccj-releases-trnciss";

    private static final String REPOSITORY_ALPHA = "rnccj-alpha";

    @Override
    @BeforeEach
    public void init(TestInfo testInfo)
            throws Exception
    {
        super.init(testInfo);
    }

    @ExtendWith({ RepositoryManagementTestExecutionListener.class,
                  ArtifactManagementTestExecutionListener.class })
    @Test
    public void testRegenerateNugetChecksum(@NugetRepository(repositoryId = REPOSITORY_RELEASES_TRNAC)
                                            Repository repository,
                                            @NugetTestArtifact(repositoryId = REPOSITORY_RELEASES_TRNAC,
                                                                       id = "org.carlspring.strongbox.checksum-second",
                                                                       versions = "1.0.0")
                                            Path artifactNupkgPath)
            throws Exception
    {
        Map<String, String> additionalProperties = Maps.newLinkedHashMap();
        additionalProperties.put("basePath", "org.carlspring.strongbox.checksum-second");
        additionalProperties.put("forceRegeneration", "false");

        testRegenerateNugetChecksum(repository,
                                    artifactNupkgPath,
                                    repository.getStorage().getId(),
                                    repository.getId(),
                                    additionalProperties);
    }

    @ExtendWith({ RepositoryManagementTestExecutionListener.class,
                         ArtifactManagementTestExecutionListener.class })
    @Test
    public void testRegenerateNugetChecksumInRepository(@NugetRepository(repositoryId = REPOSITORY_ALPHA,
                                                                         policy = RepositoryPolicyEnum.SNAPSHOT)
                                                        Repository repository,
                                                        @NugetTestArtifact(repositoryId = REPOSITORY_ALPHA,
                                                                           id = "org.carlspring.strongbox.checksum-one",<commit_msg>Issue-947: Revert method name changed by mistake.<commit_after>package org.carlspring.strongbox.cron.jobs;

import org.carlspring.strongbox.artifact.coordinates.NugetArtifactCoordinates;
import org.carlspring.strongbox.config.NugetLayoutProviderCronTasksTestConfig;
import org.carlspring.strongbox.providers.io.RepositoryFiles;
import org.carlspring.strongbox.providers.io.RepositoryPath;
import org.carlspring.strongbox.providers.io.RootRepositoryPath;
import org.carlspring.strongbox.storage.repository.Repository;
import org.carlspring.strongbox.storage.repository.RepositoryPolicyEnum;
import org.carlspring.strongbox.testing.artifact.ArtifactManagementTestExecutionListener;
import org.carlspring.strongbox.testing.artifact.NugetTestArtifact;
import org.carlspring.strongbox.testing.repository.NugetRepository;
import org.carlspring.strongbox.testing.storage.repository.RepositoryManagementTestExecutionListener;
import org.carlspring.strongbox.util.ThrowingConsumer;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.parallel.Execution;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import static java.nio.file.Files.deleteIfExists;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;

/**
 * @author <NAME>.
 * @author <NAME>
 */
@ContextConfiguration(classes = NugetLayoutProviderCronTasksTestConfig.class)
@SpringBootTest
@ActiveProfiles(profiles = "test")
@Execution(CONCURRENT)
public class RegenerateNugetChecksumCronJobTestIT
        extends BaseCronJobWithNugetIndexingTestCase
{
    private static final String STORAGE1 = "storage-nuget-rnccj";

    private static final String REPOSITORY_RELEASES_TRNAC = "rnccj-releases-trnac";

    private static final String REPOSITORY_RELEASES_TRNCIS = "rnccj-releases-trncis";

    private static final String REPOSITORY_RELEASES_TRNCISS = "rnccj-releases-trnciss";

    private static final String REPOSITORY_ALPHA = "rnccj-alpha";

    @Override
    @BeforeEach
    public void init(TestInfo testInfo)
            throws Exception
    {
        super.init(testInfo);
    }

    @ExtendWith({ RepositoryManagementTestExecutionListener.class,
                  ArtifactManagementTestExecutionListener.class })
    @Test
    public void testRegenerateNugetArtifactChecksum(@NugetRepository(repositoryId = REPOSITORY_RELEASES_TRNAC)
                                                    Repository repository,
                                                    @NugetTestArtifact(repositoryId = REPOSITORY_RELEASES_TRNAC,
                                                                       id = "org.carlspring.strongbox.checksum-second",
                                                                       versions = "1.0.0")
                                                    Path artifactNupkgPath)
            throws Exception
    {
        Map<String, String> additionalProperties = Maps.newLinkedHashMap();
        additionalProperties.put("basePath", "org.carlspring.strongbox.checksum-second");
        additionalProperties.put("forceRegeneration", "false");

        testRegenerateNugetChecksum(repository,
                                    artifactNupkgPath,
                                    repository.getStorage().getId(),
                                    repository.getId(),
                                    additionalProperties);
    }

    @ExtendWith({ RepositoryManagementTestExecutionListener.class,
                         ArtifactManagementTestExecutionListener.class })
    @Test
    public void testRegenerateNugetChecksumInRepository(@NugetRepository(repositoryId = REPOSITORY_ALPHA,
                                                                         policy = RepositoryPolicyEnum.SNAPSHOT)
                                                        Repository repository,
                                                        @NugetTestArtifact(repositoryId = REPOSITORY_ALPHA,
                                                                           id = "org.carlspring.strongbox.checksum-one",
{'fraction_non_alphanumeric': 0.07792898150116946, 'fraction_numerical': 0.0013820965341271529, 'mean_word_length': 2.6588875923765074, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5050100', 'n_tokens_mistral': 2458, 'n_tokens_neox': 2402, 'n_words': 361}