Skip to content

Commit

Permalink
test: ajustando tests dos controllers de inbound e outbound
Browse files Browse the repository at this point in the history
  • Loading branch information
oLeoBarreto committed Mar 9, 2024
1 parent f33cc9a commit c4c517f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.barreto.stockmanagement.controller.inbounds;

import com.barreto.stockmanagement.domains.documents.DocumentStatus;
import com.barreto.stockmanagement.domains.documents.Inbound;
import com.barreto.stockmanagement.domains.Product;
import com.barreto.stockmanagement.infra.DTOs.inbound.InboundPostRequestBody;
import com.barreto.stockmanagement.infra.DTOs.inbound.InboundStatusPutRequestBody;
import com.barreto.stockmanagement.useCases.inbound.InboundService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -57,6 +59,7 @@ void setUp() {
when(inboundService.createInbound(any(InboundPostRequestBody.class))).thenReturn(inbound);
when(inboundService.listAll(any(Pageable.class))).thenReturn(inboundPage);
when(inboundService.findInboundById(anyString())).thenReturn(inbound);
when(inboundService.updateInboundStatus(any(InboundStatusPutRequestBody.class))).thenReturn(inbound);
doNothing().when(inboundService).deleteInbound(anyString());

MockitoAnnotations.openMocks(this);
Expand Down Expand Up @@ -97,6 +100,16 @@ void testPostNewInbound() {
assertEquals(HttpStatus.CREATED, inbound.getStatusCode());
}

@Test
@DisplayName("Should put the status of a inbound document")
void testPutInboundStatus() {
var inboundStatusPutRequestBody = new InboundStatusPutRequestBody("inboundId", DocumentStatus.COMPLETED);
var inbound = inboundController.putInboundStatus(inboundStatusPutRequestBody);

assertNotNull(inbound.getBody());
assertEquals(HttpStatus.OK, inbound.getStatusCode());
}

@Test
@DisplayName("Should delete an existing inbound")
void testDeleteInbound() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.barreto.stockmanagement.controller.outbounds;

import com.barreto.stockmanagement.domains.documents.DocumentStatus;
import com.barreto.stockmanagement.domains.documents.Outbound;
import com.barreto.stockmanagement.domains.Product;
import com.barreto.stockmanagement.infra.DTOs.outbound.OutboundPostRequestBody;
import com.barreto.stockmanagement.infra.DTOs.outbound.OutboundStatusPutRequestBody;
import com.barreto.stockmanagement.useCases.outbound.OutboundService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -57,6 +59,7 @@ void setUp() {
when(outboundService.createNewOutbound(any(OutboundPostRequestBody.class))).thenReturn(outbound);
when(outboundService.listAll(any(Pageable.class))).thenReturn(outboundPage);
when(outboundService.findOutboundById(anyString())).thenReturn(outbound);
when(outboundService.updateOutboundStatus(any(OutboundStatusPutRequestBody.class))).thenReturn(outbound);
doNothing().when(outboundService).deleteOutbound(anyString());

MockitoAnnotations.openMocks(this);
Expand Down Expand Up @@ -95,6 +98,16 @@ void testPostNewOutbound() {
assertEquals(HttpStatus.CREATED, outbound.getStatusCode());
}

@Test
@DisplayName("Should be able to put the outbound status")
void testPutOutboundStatus() {
var outboundStatusPutRequestBody = new OutboundStatusPutRequestBody("outboundId", DocumentStatus.COMPLETED);
var outbound = outboundController.putInboundStatus(outboundStatusPutRequestBody);

assertNotNull(outbound.getBody());
assertEquals(HttpStatus.OK, outbound.getStatusCode());
}

@Test
@DisplayName("Should delete an existing outbound")
void testDeleteOutbound() {
Expand Down

0 comments on commit c4c517f

Please sign in to comment.