-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [conluz-76] Created DB migration to make field supply_id from table plants not nullable. Changed the liquibase dbchangelog schema to match version of the library used, 4.24. * [conluz-76] Implemented toString() method in class PlantId * [conluz-76] Created test for method GetPlantRepositoryDatabase::findAll()
- Loading branch information
1 parent
58d6c0e
commit a654e59
Showing
11 changed files
with
93 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/resources/db/liquibase/changelogs/make_plants_supply_id_not_null.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.24.xsd"> | ||
|
||
<changeSet id="make_plants_supply_id_not_null" author="Víctor Cañizares"> | ||
<addNotNullConstraint columnDataType="UUID" | ||
columnName="supply_id" | ||
tableName="plants"/> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...conluz/infrastructure/production/plant/get/GetPlantRepositoryDatabaseIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.lucoenergia.conluz.infrastructure.production.plant.get; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.lucoenergia.conluz.domain.admin.supply.Supply; | ||
import org.lucoenergia.conluz.domain.admin.supply.SupplyMother; | ||
import org.lucoenergia.conluz.domain.admin.supply.create.CreateSupplyRepository; | ||
import org.lucoenergia.conluz.domain.admin.user.User; | ||
import org.lucoenergia.conluz.domain.admin.user.UserMother; | ||
import org.lucoenergia.conluz.domain.admin.user.create.CreateUserRepository; | ||
import org.lucoenergia.conluz.domain.production.plant.Plant; | ||
import org.lucoenergia.conluz.domain.production.plant.PlantMother; | ||
import org.lucoenergia.conluz.domain.production.plant.create.CreatePlantRepository; | ||
import org.lucoenergia.conluz.domain.shared.SupplyId; | ||
import org.lucoenergia.conluz.domain.shared.UserId; | ||
import org.lucoenergia.conluz.domain.shared.pagination.PagedRequest; | ||
import org.lucoenergia.conluz.domain.shared.pagination.PagedResult; | ||
import org.lucoenergia.conluz.infrastructure.production.plant.PlantEntity; | ||
import org.lucoenergia.conluz.infrastructure.shared.BaseIntegrationTest; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@Transactional | ||
class GetPlantRepositoryDatabaseIntegrationTest extends BaseIntegrationTest { | ||
|
||
@Autowired | ||
private GetPlantRepositoryDatabase getPlantRepositoryDatabase; | ||
|
||
@Autowired | ||
private CreatePlantRepository createPlantRepository; | ||
@Autowired | ||
private CreateSupplyRepository createSupplyRepository; | ||
@Autowired | ||
private CreateUserRepository createUserRepository; | ||
|
||
|
||
@Test | ||
void testFindAllWithZeroResults() { | ||
|
||
PagedRequest pagedRequest = PagedRequest.of(0, 10); | ||
PagedResult<Plant> pagedResult = getPlantRepositoryDatabase.findAll(pagedRequest); | ||
|
||
assertEquals(0, pagedResult.getItems().size()); | ||
} | ||
|
||
@Test | ||
void testFindAllWithMoreThanOneResults() { | ||
|
||
User user = UserMother.randomUser(); | ||
user = createUserRepository.create(user); | ||
Supply supply = SupplyMother.random(user).build(); | ||
supply = createSupplyRepository.create(supply, UserId.of(user.getId())); | ||
Plant plantEntityOne = PlantMother.random(supply).build(); | ||
createPlantRepository.create(plantEntityOne, SupplyId.of(supply.getId())); | ||
Plant plantEntityTwo = PlantMother.random(supply).build(); | ||
createPlantRepository.create(plantEntityTwo, SupplyId.of(supply.getId())); | ||
|
||
PagedRequest pagedRequest = PagedRequest.of(0, 10); | ||
PagedResult<Plant> pagedResult = getPlantRepositoryDatabase.findAll(pagedRequest); | ||
|
||
assertEquals(2, pagedResult.getItems().size()); | ||
} | ||
} |