Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AssertJ (issue #59) #100

Merged
merged 8 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ gradle.properties
build
bin

#MacOS
# Ignore maven build output
target

# Ignore other IDEs files
.vscode

# MacOS
.DS_Store
1 change: 1 addition & 0 deletions THIRD-PARTY
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The Amazon AWS Java NIO SPI for S3 Product includes the following third-party software/licensing:

** Junit 4.x -- https://junit.org/junit4/
** AssertJ 3.x -- https://assertj.github.io/
** Logback Classic 1.2.x -- https://logback.qos.ch/ -- Copyright © 2021 QOS.ch
** Logback Core 1.2.x -- https://logback.qos.ch/ -- Copyright © 2021 QOS.ch

Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ dependencies {
implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
testImplementation 'org.mockito:mockito-core:5.4.0'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.mockito:mockito-junit-jupiter:5.4.0'


implementation platform('software.amazon.awssdk:bom:2.20.101')

implementation 'software.amazon.awssdk:s3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@


import java.util.Properties;

import static org.assertj.core.api.BDDAssertions.then;

import static software.amazon.nio.spi.s3.config.S3NioSpiConfiguration.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -21,29 +25,35 @@ public class S3NioSpiConfigurationTest {

@BeforeEach
public void setup(){
overrides.setProperty(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY, "1111");
overrides.setProperty(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY, "2");
overrides.setProperty(S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY, "1111");
overrides.setProperty(S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY, "2");
overriddenConfig = new S3NioSpiConfiguration(overrides);

badOverrides.setProperty(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY, "abcd");
badOverrides.setProperty(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY, "abcd");
badOverrides.setProperty(S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY, "abcd");
badOverrides.setProperty(S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY, "abcd");
badOverriddenConfig = new S3NioSpiConfiguration(badOverrides);
}

@Test
public void constructors() {
then(String.valueOf(config.getMaxFragmentNumber())).isEqualTo(S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT);
then(String.valueOf(config.getMaxFragmentSize())).isEqualTo(S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT);
}

@Test
public void getS3SpiReadMaxFragmentSize() {
assertEquals(Integer.parseInt(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT), config.getMaxFragmentSize());
assertEquals(Integer.parseInt(S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT), config.getMaxFragmentSize());

assertEquals(1111, overriddenConfig.getMaxFragmentSize());
assertEquals(Integer.parseInt(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT), badOverriddenConfig.getMaxFragmentSize());
assertEquals(Integer.parseInt(S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT), badOverriddenConfig.getMaxFragmentSize());
}

@Test
public void getS3SpiReadMaxFragmentNumber() {
assertEquals(Integer.parseInt(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT), config.getMaxFragmentNumber());
assertEquals(Integer.parseInt(S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT), config.getMaxFragmentNumber());

assertEquals(2, overriddenConfig.getMaxFragmentNumber());
assertEquals(Integer.parseInt(S3NioSpiConfiguration.S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT), badOverriddenConfig.getMaxFragmentNumber());
assertEquals(Integer.parseInt(S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT), badOverriddenConfig.getMaxFragmentNumber());
}

@Test
Expand Down