@Test
public void checkArtifactSizeTest()
        throws IOException
{

    long size = multipartFile.getSize();
    configurationManagementService.setArtifactMaxSize(STORAGE_ID, REPOSITORY_ID, size + 1000L);
    try
    {
        artifactOperationsValidator.checkArtifactSize(STORAGE_ID, REPOSITORY_ID, multipartFile);
    }
    catch (ArtifactResolutionException e)
    {
    }
    configurationManagementService.setArtifactMaxSize(STORAGE_ID, REPOSITORY_ID, size - 10L);
    try
    {
        artifactOperationsValidator.checkArtifactSize(STORAGE_ID, REPOSITORY_ID, multipartFile);
        fail("Should have thrown an ArtifactResolutionException.");
    }
    catch (ArtifactResolutionException e)
    {
        assertThat(true).isTrue();
    }
    configurationManagementService.setArtifactMaxSize(STORAGE_ID, REPOSITORY_ID, 0L);
    try
    {
        artifactOperationsValidator.checkArtifactSize(STORAGE_ID, REPOSITORY_ID, multipartFile);
    }
    catch (ArtifactResolutionException e)
    {
    }
    Path path = Paths.get(REPOSITORY_BASEDIR, "validate-test.jar");
    Files.createDirectories(path.getParent());
    Files.createFile(path);
    MockMultipartFile emptyFile = new MockMultipartFile("artifact",
                                                        "strongbox-validate-empty.jar",
                                                        MediaType.APPLICATION_OCTET_STREAM_VALUE,
                                                        Files.newInputStream(path));
    try
    {
        artifactOperationsValidator.checkArtifactSize(STORAGE_ID, REPOSITORY_ID, emptyFile);
        fail("Should have thrown an ArtifactResolutionException.");
    }
    catch (ArtifactResolutionException e)
    {
        assertThat(true).isTrue();
    }
    Files.delete(path);
}