-
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.
- Loading branch information
Showing
6 changed files
with
163 additions
and
48 deletions.
There are no files selected for viewing
32 changes: 0 additions & 32 deletions
32
src/main/java/it/finanze/sanita/fse2/ms/edsclient/dto/response/WhoIsResponseDTO.java
This file was deleted.
Oops, something went wrong.
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
72 changes: 72 additions & 0 deletions
72
src/test/java/it/finanze/sanita/fse2/ms/edsclient/EdsInvocationSRVTest.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,72 @@ | ||
package it.finanze.sanita.fse2.ms.edsclient; | ||
|
||
import it.finanze.sanita.fse2.ms.edsclient.client.impl.EdsClient; | ||
import it.finanze.sanita.fse2.ms.edsclient.config.Constants; | ||
import it.finanze.sanita.fse2.ms.edsclient.dto.EdsResponseDTO; | ||
import it.finanze.sanita.fse2.ms.edsclient.dto.request.PublicationRequestBodyDTO; | ||
import it.finanze.sanita.fse2.ms.edsclient.repository.entity.IniEdsInvocationETY; | ||
import it.finanze.sanita.fse2.ms.edsclient.repository.impl.EdsInvocationRepo; | ||
import it.finanze.sanita.fse2.ms.edsclient.service.impl.ConfigSRV; | ||
import it.finanze.sanita.fse2.ms.edsclient.service.impl.EdsInvocationSRV; | ||
import org.bson.Document; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.*; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ComponentScan(basePackages = {Constants.ComponentScan.BASE}) | ||
@ActiveProfiles(Constants.Profile.TEST) | ||
public class EdsInvocationSRVTest { | ||
|
||
@Autowired | ||
private EdsInvocationSRV edsInvocationSRV; | ||
|
||
@MockBean | ||
private EdsClient edsClient; | ||
|
||
@MockBean | ||
private EdsInvocationRepo edsInvocationRepo; | ||
|
||
@MockBean | ||
private ConfigSRV configSRV; | ||
|
||
@Test | ||
void testReplaceByWorkflowInstanceIdAndIdentifier(){ | ||
EdsResponseDTO out = new EdsResponseDTO(); | ||
IniEdsInvocationETY iniEdsInvocationETY = new IniEdsInvocationETY(); | ||
String workFlowInstanceId = "test"; | ||
String identifier = "test"; | ||
iniEdsInvocationETY.setWorkflowInstanceId("test"); | ||
iniEdsInvocationETY.setData(new Document("key", "test")); | ||
out.setEsito(true); | ||
|
||
when(edsClient.dispatchAndSendData(Mockito.any())).thenReturn(out); | ||
when(edsInvocationRepo.findByWorkflowInstanceId(Mockito.anyString())).thenReturn(iniEdsInvocationETY); | ||
when(configSRV.isRemoveMetadataEnable()).thenReturn(true); | ||
edsInvocationSRV.replaceByWorkflowInstanceIdAndIdentifier(identifier, workFlowInstanceId); | ||
|
||
verify(edsInvocationRepo, times(1)).removeByWorkflowInstanceId(Mockito.anyString()); | ||
} | ||
|
||
@Test | ||
void testPublishByWorkflowInstanceIdAndPriorityDocumentNotFound(){ | ||
EdsResponseDTO out; | ||
String workFlowInstanceId = "test"; | ||
PublicationRequestBodyDTO request = new PublicationRequestBodyDTO(); | ||
request.setWorkflowInstanceId(workFlowInstanceId); | ||
|
||
when(edsInvocationRepo.findByWorkflowInstanceId(Mockito.anyString())).thenReturn(null); | ||
out = edsInvocationSRV.publishByWorkflowInstanceIdAndPriority(request); | ||
|
||
|
||
assertEquals(out.getMessageError(), "Nessun documento trovato per il workflowInstanceId: " + request.getWorkflowInstanceId()); | ||
} | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
src/test/java/it/finanze/sanita/fse2/ms/edsclient/LivenessCheckCTLTest.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,33 @@ | ||
package it.finanze.sanita.fse2.ms.edsclient; | ||
|
||
import it.finanze.sanita.fse2.ms.edsclient.config.Constants; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@ActiveProfiles(Constants.Profile.TEST) | ||
@AutoConfigureMockMvc | ||
public class LivenessCheckCTLTest { | ||
|
||
@Autowired | ||
MockMvc mockMvc; | ||
|
||
@Test | ||
public void testHealthCheck() throws Exception { | ||
mockMvc.perform( | ||
get("/status") | ||
.contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk() | ||
); | ||
} | ||
} | ||
|
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