<commit_before>package org.gbif.occurrence.ws.client;

import org.gbif.api.model.occurrence.DownloadRequest;
import org.gbif.api.model.occurrence.predicate.EqualsPredicate;
import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter;
import org.gbif.api.service.occurrence.DownloadRequestService;
import org.gbif.api.service.occurrence.OccurrenceSearchService;
import org.gbif.api.service.occurrence.OccurrenceService;
import org.gbif.utils.file.properties.PropertiesUtil;
import org.gbif.ws.client.guice.AnonymousAuthModule;
import org.gbif.ws.client.guice.SingleUserAuthModule;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Properties;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;

public class OccurrenceWsClientModuleTest {

  @Test
  public void testModule() throws IOException, URISyntaxException {
    Properties properties = PropertiesUtil.loadProperties("occurrence-test.properties");
    OccurrenceWsClientModule mod = new OccurrenceWsClientModule(properties);
    Module auth = new AnonymousAuthModule();

    Injector inj = Guice.createInjector(auth, mod);
    assertNotNull(inj.getInstance(OccurrenceService.class));
  }


  @Test
  @Ignore("manual test class to verify a local download webservice")
  public void testCreate() throws Exception {
    final String USER = "nagios";

    Properties props = new Properties();
    // props.setProperty("occurrencedownload.ws.url", "http://apidev.gbif.org/");
    // props.setProperty("occurrencedownload.ws.url", "http://localhost:8080/");
    // props.setProperty("occurrencedownload.ws.url", "http://jawa.gbif.org:8080/occurrence-download-ws/");
    props.setProperty("occurrencedownload.ws.url", "http://localhost:8080/occurrence-download-ws/");
    OccurrenceWsClientModule mod = new OccurrenceWsClientModule(props);
    SingleUserAuthModule authMod = new SingleUserAuthModule(USER, USER);
    Injector inj = Guice.createInjector(authMod, mod);

    DownloadRequestService client = inj.getInstance(DownloadRequestService.class);

    DownloadRequest d =
      new DownloadRequest(new EqualsPredicate(OccurrenceSearchParameter.TAXON_KEY, "5219426"), USER, null, true);

    client.create(d);

    System.out.print(d);
  }


  private void f(){
    Properties props = new Properties();
    props.setProperty("occurrence.ws.url", "api.gbif.org/v1/");
    Injector inj = Guice.createInjector(new OccurrenceWsClientModule(props));
    OccurrenceService occService = inj.getInstance(OccurrenceService.class);
    OccurrenceSearchService searchService = inj.getInstance(OccurrenceSearchService.class);
  }

}<commit_msg>fix to match new api<commit_after>package org.gbif.occurrence.ws.client;

import org.gbif.api.model.occurrence.DownloadFormat;
import org.gbif.api.model.occurrence.DownloadRequest;
import org.gbif.api.model.occurrence.predicate.EqualsPredicate;
import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter;
import org.gbif.api.service.occurrence.DownloadRequestService;
import org.gbif.api.service.occurrence.OccurrenceSearchService;
import org.gbif.api.service.occurrence.OccurrenceService;
import org.gbif.utils.file.properties.PropertiesUtil;
import org.gbif.ws.client.guice.AnonymousAuthModule;
import org.gbif.ws.client.guice.SingleUserAuthModule;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Properties;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;

public class OccurrenceWsClientModuleTest {

  @Test
  public void testModule() throws IOException, URISyntaxException {
    Properties properties = PropertiesUtil.loadProperties("occurrence-test.properties");
    OccurrenceWsClientModule mod = new OccurrenceWsClientModule(properties);
    Module auth = new AnonymousAuthModule();

    Injector inj = Guice.createInjector(auth, mod);
    assertNotNull(inj.getInstance(OccurrenceService.class));
  }


  @Test
  @Ignore("manual test class to verify a local download webservice")
  public void testCreate() throws Exception {
    final String USER = "nagios";

    Properties props = new Properties();
    // props.setProperty("occurrencedownload.ws.url", "http://apidev.gbif.org/");
    // props.setProperty("occurrencedownload.ws.url", "http://localhost:8080/");
    // props.setProperty("occurrencedownload.ws.url", "http://jawa.gbif.org:8080/occurrence-download-ws/");
    props.setProperty("occurrencedownload.ws.url", "http://localhost:8080/occurrence-download-ws/");
    OccurrenceWsClientModule mod = new OccurrenceWsClientModule(props);
    SingleUserAuthModule authMod = new SingleUserAuthModule(USER, USER);
    Injector inj = Guice.createInjector(authMod, mod);

    DownloadRequestService client = inj.getInstance(DownloadRequestService.class);

    DownloadRequest d =
      new DownloadRequest(new EqualsPredicate(OccurrenceSearchParameter.TAXON_KEY, "5219426"), USER, null, true,
        DownloadFormat.DWCA);

    client.create(d);

    System.out.print(d);
  }


  private void f(){
    Properties props = new Properties();
    props.setProperty("occurrence.ws.url", "api.gbif.org/v1/");
    Injector inj = Guice.createInjector(new OccurrenceWsClientModule(props));
    OccurrenceService occService = inj.getInstance(OccurrenceService.class);
    OccurrenceSearchService searchService = inj.getInstance(OccurrenceSearchService.class);
  }

}
{'fraction_non_alphanumeric': 0.11326113971240902, 'fraction_numerical': 0.007101011894194923, 'mean_word_length': 5.287946428571429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7255166', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1694, 'n_words': 291}