Search in sources :

Example 1 with ArchiveSupport

use of com.mercedesbenz.sechub.commons.archive.ArchiveSupport in project sechub by mercedes-benz.

the class PDSFileUploadJobServiceTest method beforeEach.

@BeforeEach
void beforeEach() throws Exception {
    tmpUploadPath = TestUtil.createTempDirectoryInBuildFolder("pds-upload");
    jobUUID = UUID.randomUUID();
    checksumService = mock(PDSFileChecksumSHA256Service.class);
    workspaceService = mock(PDSWorkspaceService.class);
    storageService = mock(PDSMultiStorageService.class);
    configuration = mock(UploadSizeConfiguration.class);
    when(configuration.getMaxUploadSizeInBytes()).thenReturn(2048L);
    archiveSupportProvider = mock(PDSArchiveSupportProvider.class);
    archiveSupport = mock(ArchiveSupport.class);
    when(archiveSupportProvider.getArchiveSupport()).thenReturn(archiveSupport);
    storage = mock(JobStorage.class);
    when(storageService.getJobStorage(jobUUID)).thenReturn(storage);
    when(workspaceService.getUploadFolder(jobUUID)).thenReturn(new File(tmpUploadPath.toFile(), jobUUID.toString()));
    repository = mock(PDSJobRepository.class);
    job = new PDSJob();
    job.uUID = jobUUID;
    Optional<PDSJob> jobOption = Optional.of(job);
    when(repository.findById(jobUUID)).thenReturn(jobOption);
    serviceToTest = new PDSFileUploadJobService();
    serviceToTest.checksumSHA256Service = checksumService;
    serviceToTest.workspaceService = workspaceService;
    serviceToTest.repository = repository;
    serviceToTest.storageService = storageService;
    serviceToTest.archiveSupportProvider = archiveSupportProvider;
    serviceToTest.configuration = configuration;
    when(checksumService.hasCorrectChecksum(eq(ACCEPTED_CHECKSUM), any())).thenReturn(true);
    when(checksumService.hasCorrectChecksum(eq(NOT_ACCEPTED_CHECKSUM), any())).thenReturn(false);
}
Also used : PDSFileChecksumSHA256Service(com.mercedesbenz.sechub.pds.util.PDSFileChecksumSHA256Service) PDSMultiStorageService(com.mercedesbenz.sechub.pds.storage.PDSMultiStorageService) PDSArchiveSupportProvider(com.mercedesbenz.sechub.pds.util.PDSArchiveSupportProvider) UploadSizeConfiguration(com.mercedesbenz.sechub.pds.UploadSizeConfiguration) ArchiveSupport(com.mercedesbenz.sechub.commons.archive.ArchiveSupport) JobStorage(com.mercedesbenz.sechub.storage.core.JobStorage) File(java.io.File) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ArchiveSupport (com.mercedesbenz.sechub.commons.archive.ArchiveSupport)1 UploadSizeConfiguration (com.mercedesbenz.sechub.pds.UploadSizeConfiguration)1 PDSMultiStorageService (com.mercedesbenz.sechub.pds.storage.PDSMultiStorageService)1 PDSArchiveSupportProvider (com.mercedesbenz.sechub.pds.util.PDSArchiveSupportProvider)1 PDSFileChecksumSHA256Service (com.mercedesbenz.sechub.pds.util.PDSFileChecksumSHA256Service)1 JobStorage (com.mercedesbenz.sechub.storage.core.JobStorage)1 File (java.io.File)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)1