<commit_before>package org.apache.continuum.buildagent.manager;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationException;
import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
import org.apache.continuum.buildagent.model.LocalRepository;
import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
import org.apache.maven.continuum.release.ContinuumReleaseException;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import static org.mockito.Mockito.*;

/**
 * For the CONTINUUM-2391 tests, checking of the local repository details is in ContinuumReleaseManagerStub. An
 * exception is thrown if the set local repository in the repository map is incorrect.
 */
public class BuildAgentReleaseManagerTest
    extends PlexusInSpringTestCase
{

    public static final String DEFAULT_NAME = "DEFAULT";

    public static final String UNKNOWN_NAME = "NON-EXISTENT";

    private BuildAgentConfigurationService buildAgentConfigurationService;

    private DefaultBuildAgentReleaseManager releaseManager;

    protected void setUp()
        throws Exception
    {
        super.setUp();

        releaseManager = (DefaultBuildAgentReleaseManager) lookup( BuildAgentReleaseManager.class );

        buildAgentConfigurationService = mock( BuildAgentConfigurationService.class );

        releaseManager.setBuildAgentConfigurationService( buildAgentConfigurationService );

        final List<LocalRepository> localRepos = createLocalRepositories();
        final File workingDir = new File( getBasedir(), "target/test-classes/working-dir" );

        for ( LocalRepository localRepo : localRepos )
        {
            String repoName = localRepo.getName();
            when( buildAgentConfigurationService.getLocalRepositoryByName( repoName ) ).thenReturn( localRepo );
            when( buildAgentConfigurationService.getLocalRepositoryByName( repoName.toUpperCase() ) ).thenReturn(
                localRepo );
        }
        when( buildAgentConfigurationService.getLocalRepositoryByName( UNKNOWN_NAME ) ).thenThrow(
            new BuildAgentConfigurationException( "could not locate the repo" ) );

        when( buildAgentConfigurationService.getWorkingDirectory( 1 ) ).thenReturn( workingDir );
    }

    protected void tearDown()
        throws Exception
    {
        releaseManager = null;

        super.tearDown();
    }<commit_msg>Release tests created 'release-#' directories in root of project.<commit_after>package org.apache.continuum.buildagent.manager;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationException;
import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
import org.apache.continuum.buildagent.model.LocalRepository;
import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
import org.apache.maven.continuum.release.ContinuumReleaseException;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
 * For the CONTINUUM-2391 tests, checking of the local repository details is in ContinuumReleaseManagerStub. An
 * exception is thrown if the set local repository in the repository map is incorrect.
 */
public class BuildAgentReleaseManagerTest
    extends PlexusInSpringTestCase
{

    public static final String DEFAULT_NAME = "DEFAULT";

    public static final String UNKNOWN_NAME = "NON-EXISTENT";

    private BuildAgentConfigurationService buildAgentConfigurationService;

    private DefaultBuildAgentReleaseManager releaseManager;

    protected void setUp()
        throws Exception
    {
        super.setUp();

        releaseManager = (DefaultBuildAgentReleaseManager) lookup( BuildAgentReleaseManager.class );

        buildAgentConfigurationService = mock( BuildAgentConfigurationService.class );

        releaseManager.setBuildAgentConfigurationService( buildAgentConfigurationService );

        final List<LocalRepository> localRepos = createLocalRepositories();
        final File workingDir = new File( getBasedir(), "target/test-classes/working-dir" );

        for ( LocalRepository localRepo : localRepos )
        {
            String repoName = localRepo.getName();
            when( buildAgentConfigurationService.getLocalRepositoryByName( repoName ) ).thenReturn( localRepo );
            when( buildAgentConfigurationService.getLocalRepositoryByName( repoName.toUpperCase() ) ).thenReturn(
                localRepo );
        }
        when( buildAgentConfigurationService.getLocalRepositoryByName( UNKNOWN_NAME ) ).thenThrow(
            new BuildAgentConfigurationException( "could not locate the repo" ) );

        when( buildAgentConfigurationService.getWorkingDirectory( 1 ) ).thenReturn( workingDir );
        when( buildAgentConfigurationService.getWorkingDirectory() ).thenReturn( workingDir );
    }

    protected void tearDown()
        throws Exception
    {
        releaseManager = null;

        super.tearDown();
    }
{'fraction_non_alphanumeric': 0.07237410071942446, 'fraction_numerical': 0.002589928057553957, 'mean_word_length': 4.051598837209302, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3443201', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1677, 'n_words': 533}