Skip to content

Commit

Permalink
refactor: Use Optional in repository tests
Browse files Browse the repository at this point in the history
Refactor the repository tests to use `Optional` when retrieving entities by UUID. This change improves code readability and ensures safer handling of null values.
  • Loading branch information
amengus87 committed May 30, 2024
1 parent 9128dde commit b289dd6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void insertFarms() {
farm.setName(farmName);
farmRepository.save(farm);

FarmEntity retrievedFarm = farmRepository.getByUuid(farm.getUuid());
FarmEntity retrievedFarm = farmRepository.getByUuid(farm.getUuid()).orElseThrow();
assertNotNull(farmRepository.getByUuid(retrievedFarm.getUuid()));
assertEquals(farmName, retrievedFarm.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void insertProviders() {
provider.setType(ProviderType.ONNX);
providerRepository.save(provider);

ProviderEntity retrievedProvider = providerRepository.getByUuid(provider.getUuid());
ProviderEntity retrievedProvider = providerRepository.getByUuid(provider.getUuid()).orElseThrow();
assertNotNull(providerRepository.getByUuid(retrievedProvider.getUuid()));
assertEquals(providerName, retrievedProvider.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void insertSilos() {
silo.setName(siloName);
siloRepository.save(silo);

SiloEntity retrievedSilo = siloRepository.getByUuid(silo.getUuid());
SiloEntity retrievedSilo = siloRepository.getByUuid(silo.getUuid()).orElseThrow();
assertNotNull(siloRepository.getByUuid(retrievedSilo.getUuid()));
assertEquals(siloName, retrievedSilo.getName());
}
Expand Down

0 comments on commit b289dd6

Please sign in to comment.