-
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.
production modification save, backend errors displayed in frontend
- Loading branch information
1 parent
4f50cb7
commit 6df479b
Showing
16 changed files
with
149 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
server.port=8080 | ||
server.error.include-message=always | ||
spring.jackson.date-format=eu.viandeendirect.RFC3339DateFormat | ||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false | ||
logging.level.org.springframework.security=TRACE |
56 changes: 56 additions & 0 deletions
56
...rc/test/java/eu/viandeendirect/service/TestBeefProductionService_checkBeefProduction.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,56 @@ | ||
package eu.viandeendirect.service; | ||
|
||
import eu.viandeendirect.model.BeefProduction; | ||
import eu.viandeendirect.model.Sale; | ||
import eu.viandeendirect.repository.ProductionRepository; | ||
import eu.viandeendirect.repository.SaleRepository; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles(value = "test") | ||
@ExtendWith({SpringExtension.class}) | ||
class TestBeefProductionService_checkBeefProduction { | ||
@Autowired | ||
BeefProductionService beefProductionService; | ||
|
||
@Autowired | ||
ProductionRepository productionRepository; | ||
|
||
@Autowired | ||
SaleRepository saleRepository; | ||
|
||
@Test | ||
void should_not_raise_an_error_if_production_not_related_to_a_sale() { | ||
// given | ||
BeefProduction production = productionRepository.save(new BeefProduction()); | ||
|
||
// when / then | ||
Assertions.assertThatNoException().isThrownBy(() -> beefProductionService.checkBeefProduction(production)); | ||
} | ||
|
||
@Test | ||
void should_raise_an_error_if_production_related_to_a_sale() { | ||
// given | ||
BeefProduction production = productionRepository.save(new BeefProduction()); | ||
Sale sale = new Sale(); | ||
sale.setProductions(List.of(production)); | ||
saleRepository.save(sale); | ||
|
||
// when / then | ||
Assertions.assertThatThrownBy(() -> beefProductionService.checkBeefProduction(production)) | ||
.isInstanceOf(ResponseStatusException.class) | ||
.satisfies(throwable -> assertThat(((ResponseStatusException) throwable).getBody().getDetail()).isEqualTo("Il n'est pas possible de modifier une production déjà mise en vente.")); | ||
} | ||
|
||
} |
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
Oops, something went wrong.