Skip to content

Commit

Permalink
#754 | Fix MetadataDiffControllerIntegrationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Sep 20, 2024
1 parent b4e062d commit 7d54e5b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.*;
import java.io.File;
import java.io.IOException;
import java.util.*;

@Service
public class MetadataDiffService {

private static final Logger logger = LoggerFactory.getLogger(MetadataDiffService.class);
private static final ObjectMapper objectMapper = new ObjectMapper();

private final MetadataBundleAndFileHandler bundleAndFileHandler;
private final MetadataDiffChecker diffChecker;
private final MetadataDiffOutputGenerator outputGenerator;

@Autowired
public MetadataDiffService(MetadataBundleAndFileHandler bundleAndFileHandler, MetadataDiffChecker diffChecker, MetadataDiffOutputGenerator outputGenerator) {
public MetadataDiffService(MetadataBundleAndFileHandler bundleAndFileHandler, MetadataDiffChecker diffChecker) {
this.bundleAndFileHandler = bundleAndFileHandler;
this.diffChecker = diffChecker;
this.outputGenerator = outputGenerator;
}

public Map<String, Object> compareMetadataZips(MultipartFile zipFile1, MultipartFile zipFile2) throws IOException {
public Map<String, Object> compareMetadataZips(MultipartFile zipFile1, MultipartFile zipFile2) {
Map<String, Object> result = new HashMap<>();
File tempDir1 = null, tempDir2 = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.avni.server.service;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import static org.junit.Assert.*;

public class MetadataDiffServiceTest {

private MetadataBundleAndFileHandler bundleAndFileHandler;
Expand All @@ -28,7 +28,7 @@ public void setUp() {
bundleAndFileHandler = new MetadataBundleAndFileHandler();
outputGenerator = new MetadataDiffOutputGenerator();
diffChecker = new MetadataDiffChecker(outputGenerator);
metadataDiffService = new MetadataDiffService(bundleAndFileHandler, diffChecker, outputGenerator);
metadataDiffService = new MetadataDiffService(bundleAndFileHandler, diffChecker);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package org.avni.server.web;

import org.avni.server.common.AbstractControllerIntegrationTest;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;


@Sql(value = {"/test-data.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(value = {"/tear-down.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public class MetadataDiffControllerIntegrationTest extends AbstractControllerIntegrationTest {

@Before
public void setUp() throws Exception {
super.setUp();
setUser("demo-user");
}

@Test
public void testCompareMetadataZips() throws Exception {
setUser("demo-user");
MockMultipartFile file1 = new MockMultipartFile("file1", "file1.zip", MediaType.MULTIPART_FORM_DATA_VALUE, "zip file content".getBytes());
MockMultipartFile file2 = new MockMultipartFile("file2", "file2.zip", MediaType.MULTIPART_FORM_DATA_VALUE, "zip file content".getBytes());

Expand Down

0 comments on commit 7d54e5b

Please sign in to comment.