<commit_before>package org.axway.grapes.server.webapp.resources;

import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.yammer.dropwizard.auth.AuthenticationException;
import com.yammer.dropwizard.auth.basic.BasicAuthProvider;
import com.yammer.dropwizard.testing.ResourceTest;
import com.yammer.dropwizard.views.ViewMessageBodyWriter;

import org.axway.grapes.commons.api.ServerAPI;
import org.axway.grapes.commons.datamodel.*;
import org.axway.grapes.server.GrapesTestUtils;
import org.axway.grapes.server.config.GrapesEmailConfig;
import org.axway.grapes.server.config.GrapesServerConfig;
import org.axway.grapes.server.config.Messages;
import org.axway.grapes.server.core.options.FiltersHolder;
import org.axway.grapes.server.core.services.email.MessageKey;
import org.axway.grapes.server.db.ModelMapper;
import org.axway.grapes.server.db.RepositoryHandler;
import org.axway.grapes.server.db.datamodel.*;
import org.axway.grapes.server.webapp.auth.GrapesAuthenticator;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;


public class ArtifactResourceTest extends ResourceTest {

    private RepositoryHandler repositoryHandler;
    private final String templatePath = GrapesTestUtils.class.getResource("all-messages-pretty-print.txt").getPath().replaceFirst("/", "");

    @Override
    protected void setUpResources() throws Exception {
        repositoryHandler = GrapesTestUtils.getRepoHandlerMock();

        ArtifactResource resource = new ArtifactResource(repositoryHandler, getGrapesConfig());
        addProvider(new BasicAuthProvider<DbCredential>(new GrapesAuthenticator(repositoryHandler), "test auth"));
        addProvider(ViewMessageBodyWriter.class);
        addResource(resource);
    }
    
    private GrapesServerConfig getGrapesConfig(){
        GrapesServerConfig config = mock(GrapesServerConfig.class);
        List<String> validatedTypes = new ArrayList<String>();
        validatedTypes.add("filetype1");
        validatedTypes.add("filetype2");
        when(config.getExternalValidatedTypes()).thenReturn(validatedTypes);
        when(config.getArtifactNotificationRecipients()).thenReturn(new String[] {"<EMAIL>"});

        GrapesEmailConfig emailCfgMock = mock(GrapesEmailConfig.class);
        when(config.getGrapesEmailConfig()).thenReturn(emailCfgMock);

        Properties p = new Properties();
        p.setProperty("mail.smtp.host", "1");
        p.setProperty("mail.smtp.user", "2");
        p.setProperty("mail.smtp.password", "3");
        p.setProperty("mail.smtp.ssl.trust", "4");
        p.setProperty("mail.smtp.from", "5");<commit_msg>ECDDEV-794 - Fixing test issue.<commit_after>package org.axway.grapes.server.webapp.resources;

import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.yammer.dropwizard.auth.AuthenticationException;
import com.yammer.dropwizard.auth.basic.BasicAuthProvider;
import com.yammer.dropwizard.testing.ResourceTest;
import com.yammer.dropwizard.views.ViewMessageBodyWriter;

import org.axway.grapes.commons.api.ServerAPI;
import org.axway.grapes.commons.datamodel.*;
import org.axway.grapes.server.GrapesTestUtils;
import org.axway.grapes.server.config.GrapesEmailConfig;
import org.axway.grapes.server.config.GrapesServerConfig;
import org.axway.grapes.server.config.Messages;
import org.axway.grapes.server.core.options.FiltersHolder;
import org.axway.grapes.server.core.services.email.MessageKey;
import org.axway.grapes.server.db.ModelMapper;
import org.axway.grapes.server.db.RepositoryHandler;
import org.axway.grapes.server.db.datamodel.*;
import org.axway.grapes.server.webapp.auth.GrapesAuthenticator;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;


public class ArtifactResourceTest extends ResourceTest {

    private RepositoryHandler repositoryHandler;
    private final String templatePath = GrapesTestUtils.class.getResource("all-messages-pretty-print.txt").getPath();

    @Override
    protected void setUpResources() throws Exception {
        repositoryHandler = GrapesTestUtils.getRepoHandlerMock();

        ArtifactResource resource = new ArtifactResource(repositoryHandler, getGrapesConfig());
        addProvider(new BasicAuthProvider<DbCredential>(new GrapesAuthenticator(repositoryHandler), "test auth"));
        addProvider(ViewMessageBodyWriter.class);
        addResource(resource);
    }
    
    private GrapesServerConfig getGrapesConfig(){
        GrapesServerConfig config = mock(GrapesServerConfig.class);
        List<String> validatedTypes = new ArrayList<String>();
        validatedTypes.add("filetype1");
        validatedTypes.add("filetype2");
        when(config.getExternalValidatedTypes()).thenReturn(validatedTypes);
        when(config.getArtifactNotificationRecipients()).thenReturn(new String[] {"<EMAIL>"});

        GrapesEmailConfig emailCfgMock = mock(GrapesEmailConfig.class);
        when(config.getGrapesEmailConfig()).thenReturn(emailCfgMock);

        Properties p = new Properties();
        p.setProperty("mail.smtp.host", "1");
        p.setProperty("mail.smtp.user", "2");
        p.setProperty("mail.smtp.password", "3");
        p.setProperty("mail.smtp.ssl.trust", "4");
        p.setProperty("mail.smtp.from", "5");
{'fraction_non_alphanumeric': 0.1178125, 'fraction_numerical': 0.00265625, 'mean_word_length': 5.021636876763876, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6038831', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1972, 'n_words': 284}