package org.innovateuk.ifs.filestorage.storage.tika;

import org.innovateuk.ifs.filestorage.cfg.StorageServiceConfiguration;
import org.innovateuk.ifs.filestorage.exception.MimeMismatchException;
import org.innovateuk.ifs.filestorage.storage.StorageService;
import org.innovateuk.ifs.filestorage.storage.StorageServiceHelper;
import org.innovateuk.ifs.filestorage.storage.validator.TikaFileValidator;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;

import java.nio.charset.StandardCharsets;

import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
@Import(StorageServiceConfiguration.class)
class TikaFileValidatorTest {

    private byte[] JSON = "{some: json}".getBytes(StandardCharsets.UTF_8);

    @MockBean
    private StorageService storageService;

    @MockBean
    private StorageServiceHelper storageServiceHelper;

    @Autowired
    private TikaFileValidator tikaFileValidator;

    @Test
    void validatePayload() {
        tikaFileValidator.validatePayload(MediaType.APPLICATION_JSON_VALUE, JSON, "foo.json");
    }

    @Test
    void validatePayloadFail() {
        assertThrows(
                MimeMismatchException.class,
                () -> tikaFileValidator.validatePayload(MediaType.IMAGE_GIF_VALUE, JSON, "foo.json")
        );
    }
}
@@ -1209,16 +1209,20 @@
 ePayload
+Fail
 () %7B%0A   
@@ -1317,58 +1317,8 @@
 %22);%0A
-    %7D%0A%0A    @Test%0A    void validatePayloadFail() %7B%0A
     

fix test