Skip to content

Commit

Permalink
fixed violations
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed Jan 16, 2025
1 parent 205d23c commit 98781bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
4 changes: 2 additions & 2 deletions docs/guide/src/docs/asciidoc/dynamodb.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ include::{root-dir}/subprojects/micronaut-amazon-awssdk-dynamodb-loader/src/test
<1> Test must be annotated wiht `@MicronautTest` to allow loader injection
<2> Property `aws.dynamodb.create-tables` guarantees that the tables are created automatically
<3> https://agorapulse.github.io/testing-libraries/#_fixt[Fixt] is very convenient way how to keep your test fixtures organized and can be easily used with the loader
<4> Load the data from the CSV file
<5> The mapping is specified as map with the entity types as keys and iterables of the CSV files as values
<4> The mapping is specified as map with the entity types as keys and iterables of the CSV files as values
<5> Load the data from the CSV file
<6> After loading the data, the entities according to the rows in the CSV file are available in the database

This is how the files are laid out for this particular example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;

import java.time.Instant;
import java.util.List;
Expand All @@ -35,29 +34,22 @@
@Property(name = "aws.dynamodb.create-tables", value = "true") // <2>
class DynamoDbLoaderTest {

private static final Fixt fixt = Fixt.create(DynamoDbLoaderTest.class); // <3>
private static final Fixt FIXT = Fixt.create(DynamoDbLoaderTest.class); // <3>

@Inject DynamoDbLoader loader;
@Inject DynamoDBServiceProvider provider;

@Test
void loadIntoDynamoDb() {
TestEntity referenceEntity = getReferenceEntity();

Object loadedValue = Flux.from(
loader.load( // <4>
fixt::readText,
Map.of(
TestEntity.class, List.of("test-entity.csv") // <5>
)
)
).blockLast();

assertInstanceOf(TestEntity.class, loadedValue);
Map<Class<?>, Iterable<String>> mappings = Map.of(
TestEntity.class, List.of("test-entity.csv") // <4>
);

assertEquals(referenceEntity, loadedValue);
loader.loadAll(FIXT::readText, mappings); // <5>

TestEntity fromDb = provider.findOrCreate(TestEntity.class).get("1", null); // <6>
TestEntity referenceEntity = getReferenceEntity();
assertEquals(referenceEntity, fromDb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ public int hashCode() {

@Override
public String toString() {
return "TestEntity{" + "id='" + id + '\'' +
", name='" + name + '\'' +
", created=" + created +
", active=" + active +
", count=" + count +
", value=" + value +
", data=" + data +
'}';
return "TestEntity{id='%s', name='%s', created=%s, active=%s, count=%d, value=%s, data=%s}".formatted(id, name, created, active, count, value, data);
}
}

0 comments on commit 98781bd

Please sign in to comment.