Sha256: 0b558879c754a6850253c8488ce0915c280569c9cedc7d11d582a2b301e14472

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

package org.embulk.output.s3v2.util;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.nio.ByteBuffer;

/**
 * @see ThresholdComputation
 */
@ExtendWith(MockitoExtension.class)
public class ThresholdComputationTests
{
    @Test
    @DisplayName("Threshold check returns true")
    public void testThresholdCheckReturnsTrue() throws Exception
    {
        ByteBuffer bf = ByteBuffer.allocate(1000001);
        Assertions.assertTrue(ThresholdComputation.largerThanThreshold("1MB", bf.capacity()));
    }

    @Test
    @DisplayName("Threshold check returns false")
    public void testThresholdCheckReturnsFalse() throws Exception
    {
        ByteBuffer bf = ByteBuffer.allocate(1000000);
        Assertions.assertFalse(ThresholdComputation.largerThanThreshold("1MB", bf.capacity()));
    }

    @Test
    @DisplayName("Invalid threshold string")
    public void testInvalidThresholdString() throws Exception
    {
        ByteBuffer bf = ByteBuffer.allocate(1000000);
        String threshold = "1MB1MB";
        IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class,
                () -> ThresholdComputation.largerThanThreshold(threshold, bf.capacity()));
        Assertions.assertEquals("Unrecognized value of multipart_threshold: " + threshold, ex.getMessage());
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
embulk-output-s3v2-0.3.0 src/test/java/org/embulk/output/s3v2/util/ThresholdComputationTests.java
embulk-output-s3v2-0.2.1 src/test/java/org/embulk/output/s3v2/util/ThresholdComputationTests.java
embulk-output-s3v2-0.2.0 src/test/java/org/embulk/output/s3v2/util/ThresholdComputationTests.java