<commit_before>package io.oasp.gastronomy.restaurant.offermanagement.batch.impl.productimport;

import io.oasp.gastronomy.restaurant.general.common.AbstractSpringBatchIntegrationTest;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.Offermanagement;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.to.DrinkEto;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.to.MealEto;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.to.ProductEto;
import io.oasp.module.configuration.common.api.ApplicationConfigurationConstants;

import java.util.List;

import javax.inject.Inject;

import org.junit.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.test.context.ContextConfiguration;

/**
 * End-To-End test job "import offer management from csv"
 *
 * @author jczas
 */
@ContextConfiguration(locations = { ApplicationConfigurationConstants.BEANS_BATCH })
public class ProductImportJobTest extends AbstractSpringBatchIntegrationTest {

  @Inject
  private Job productImportJob;

  @Inject
  private Offermanagement offermanagement;

  /**
   * @throws Exception thrown by JobLauncherTestUtils
   */
  @Test
  public void testJob() throws Exception {

    // configure job
    JobParametersBuilder jobParameterBuilder = new JobParametersBuilder();
    jobParameterBuilder.addString("drinks.file", "classpath:ProductImportJobTest/data/drinks.csv");
    jobParameterBuilder.addString("meals.file", "classpath:ProductImportJobTest/data/meals.csv");
    JobParameters jobParameters = jobParameterBuilder.toJobParameters();

    // run job
    JobExecution jobExecution = getJobLauncherTestUtils(this.productImportJob).launchJob(jobParameters);

    // check results
    // - job status
    assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED);

    // - imported data (there is 7 products in setup data)
    List<ProductEto> allProducts = this.offermanagement.findAllProducts();
    assertThat(allProducts).hasSize(7);

    // - exemplary drink
    DrinkEto drink = (DrinkEto) allProducts.get(0);
    assertThat(drink.getName()).isEqualTo("Heineken");
    assertThat(drink.getDescription()).isEqualTo("Pretty good beer");
    assertThat(drink.getPictureId()).isEqualTo(1);
    assertThat(drink.isAlcoholic()).isTrue();

    // - exemplary meal
    MealEto meal = (MealEto) allProducts.get(3);
    assertThat(meal.getName()).isEqualTo("Bratwurst");
    assertThat(meal.getDescription()).isEqualTo("Tasty sausage");
    assertThat(meal.getPictureId()).isEqualTo(1);
  }
}
<commit_msg>hack to make build work in travis (at least a try)<commit_after>package io.oasp.gastronomy.restaurant.offermanagement.batch.impl.productimport;

import java.util.List;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.junit.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.test.context.ContextConfiguration;

import io.oasp.gastronomy.restaurant.general.common.AbstractSpringBatchIntegrationTest;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.Offermanagement;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.to.DrinkEto;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.to.MealEto;
import io.oasp.gastronomy.restaurant.offermanagement.logic.api.to.ProductEto;
import io.oasp.module.configuration.common.api.ApplicationConfigurationConstants;

/**
 * End-To-End test job "import offer management from csv"
 *
 * @author jczas
 */
@ContextConfiguration(locations = { ApplicationConfigurationConstants.BEANS_BATCH })
public class ProductImportJobTest extends AbstractSpringBatchIntegrationTest {

  @PersistenceContext
  private EntityManager entityManager;

  @Inject
  private Job productImportJob;

  @Inject
  private Offermanagement offermanagement;

  /**
   * @throws Exception thrown by JobLauncherTestUtils
   */
  @Test
  public void testJob() throws Exception {

    // TODO hohwille temporary hack for travis build failure
    this.entityManager.createNativeQuery("Delete from ProductEntity");

    // configure job
    JobParametersBuilder jobParameterBuilder = new JobParametersBuilder();
    jobParameterBuilder.addString("drinks.file", "classpath:ProductImportJobTest/data/drinks.csv");
    jobParameterBuilder.addString("meals.file", "classpath:ProductImportJobTest/data/meals.csv");
    JobParameters jobParameters = jobParameterBuilder.toJobParameters();

    // run job
    JobExecution jobExecution = getJobLauncherTestUtils(this.productImportJob).launchJob(jobParameters);

    // check results
    // - job status
    assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED);

    // - imported data (there is 7 products in setup data)
    List<ProductEto> allProducts = this.offermanagement.findAllProducts();
    assertThat(allProducts).hasSize(7);

    // - exemplary drink
    DrinkEto drink = (DrinkEto) allProducts.get(0);
    assertThat(drink.getName()).isEqualTo("Heineken");
    assertThat(drink.getDescription()).isEqualTo("Pretty good beer");
    assertThat(drink.getPictureId()).isEqualTo(1);
    assertThat(drink.isAlcoholic()).isTrue();

    // - exemplary meal
    MealEto meal = (MealEto) allProducts.get(3);
    assertThat(meal.getName()).isEqualTo("Bratwurst");
    assertThat(meal.getDescription()).isEqualTo("Tasty sausage");
    assertThat(meal.getPictureId()).isEqualTo(1);
  }
}

{'fraction_non_alphanumeric': 0.10621375310687656, 'fraction_numerical': 0.001988400994200497, 'mean_word_length': 4.625349487418453, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7666783', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1746, 'n_words': 281}