Skip to content

Commit

Permalink
Merge pull request #2 from mrizzi/m-brophy-TACKLE-58
Browse files Browse the repository at this point in the history
TACKLE-58: moved MultipartImportBody and added RestClient annotation in tests
  • Loading branch information
m-brophy authored May 27, 2021
2 parents d7af407 + 3307be6 commit 7e4f4c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.tackle.applicationimporter;
package io.tackle.applicationinventory;

import java.io.InputStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
import io.tackle.applicationimporter.MultipartImportBody;
import io.tackle.applicationinventory.BusinessService;
import io.tackle.applicationinventory.MultipartImportBody;
import io.tackle.applicationinventory.TagType;
import io.tackle.applicationinventory.entities.ApplicationImport;
import io.tackle.applicationinventory.exceptions.ApplicationsInventoryException;
Expand Down
24 changes: 13 additions & 11 deletions src/test/java/io/tackle/applicationimporter/ImportServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.mockito.InjectMock;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.config.EncoderConfig;
import io.tackle.applicationinventory.BusinessService;
import io.tackle.applicationinventory.MultipartImportBody;
import io.tackle.applicationinventory.TagType;
import io.tackle.applicationinventory.entities.ApplicationImport;
import io.tackle.applicationinventory.mapper.ApplicationInventoryAPIMapper;
import io.tackle.applicationinventory.service.BusinessServiceService;
import io.tackle.applicationinventory.service.ImportService;
import io.tackle.applicationimporter.MultipartImportBody;
import io.tackle.applicationinventory.service.TagTypeService;
import io.tackle.commons.testcontainers.KeycloakTestResource;
import io.tackle.commons.testcontainers.PostgreSQLDatabaseTestResource;
import io.tackle.commons.tests.SecuredResourceTest;
import org.apache.commons.io.FileUtils;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.core.MediaType;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static io.restassured.RestAssured.given;
import static javax.transaction.Transactional.TxType.REQUIRED;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;

@QuarkusTest
@QuarkusTestResource(value = PostgreSQLDatabaseTestResource.class,
Expand All @@ -57,12 +58,13 @@
public class ImportServiceTest extends SecuredResourceTest {

@InjectMock
@RestClient
TagTypeService mockTagTypeService;

@InjectMock
@RestClient
BusinessServiceService mockBusinessServiceService;


@BeforeAll
public static void init() {
PATH = "/file/upload";
Expand Down Expand Up @@ -101,7 +103,7 @@ protected void testImportServicePost() {
tagType1.tags.add(tag);
tagTypes.add(tagType1);
Mockito.when(mockTagTypeService.getListOfTagTypes()).thenReturn(tagTypes);
QuarkusMock.installMockForInstance(mockTagTypeService, TagTypeService.class);
// QuarkusMock.installMockForInstance(mockTagTypeService, TagTypeService.class);

//BusinessServiceService mockBusinessServiceService = Mockito.mock(BusinessServiceService.class);
Set<BusinessService> businessServices = new HashSet<>() ;
Expand All @@ -110,7 +112,7 @@ protected void testImportServicePost() {
businessService.name = "Food2Go";
businessServices.add(businessService);
Mockito.when(mockBusinessServiceService.getListOfBusinessServices()).thenReturn(businessServices);
QuarkusMock.installMockForInstance(mockBusinessServiceService, BusinessServiceService.class);
// QuarkusMock.installMockForInstance(mockBusinessServiceService, BusinessServiceService.class);

Response response = given()
.config(RestAssured.config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs("multipart/form-data", ContentType.JSON)))
Expand Down

0 comments on commit 7e4f4c4

Please sign in to comment.