-
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
11 changed files
with
135 additions
and
43 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
69 changes: 54 additions & 15 deletions
69
.../pagopa/interop/signalhub/pull/service/repository/ConsumerEServiceRepositoryImplTest.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 |
---|---|---|
@@ -1,23 +1,62 @@ | ||
package it.pagopa.interop.signalhub.pull.service.repository; | ||
|
||
import it.pagopa.interop.signalhub.pull.service.cache.model.ConsumerEServiceCache; | ||
import it.pagopa.interop.signalhub.pull.service.cache.repository.ConsumerEServiceCacheRepository; | ||
import it.pagopa.interop.signalhub.pull.service.config.BaseTest; | ||
import it.pagopa.interop.signalhub.pull.service.entities.ConsumerEService; | ||
import it.pagopa.interop.signalhub.pull.service.mapper.ConsumerEServiceMapper; | ||
import it.pagopa.interop.signalhub.pull.service.service.impl.ConsumerServiceImpl; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate; | ||
import reactor.core.publisher.Mono; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import java.sql.Timestamp; | ||
import java.time.Instant; | ||
import java.util.List; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ConsumerEServiceRepositoryImplTest { | ||
class ConsumerEServiceRepositoryImplTest extends BaseTest.WithR2DBC { | ||
|
||
private static final String correctEservice = "1234"; | ||
private static final String correctConsumer = "1234"; | ||
private static final String correctState = "PUBLISHED"; | ||
private static final String incorrectState = "ACTIVE"; | ||
|
||
@Autowired | ||
private ConsumerEServiceRepository consumerEServiceRepository; | ||
|
||
@BeforeEach | ||
void setUp(){ | ||
consumerEServiceRepository.save(getEntity()); | ||
} | ||
|
||
@Test | ||
void whenFindOrganizationWithBadlyParamThenReturnNull(){ | ||
List<ConsumerEService> entity = | ||
consumerEServiceRepository.findByConsumerIdAndEServiceIdAndState( | ||
correctEservice, | ||
correctConsumer, | ||
incorrectState).collectList().block(); | ||
|
||
Assertions.assertTrue(entity.isEmpty()); | ||
} | ||
|
||
|
||
@Test | ||
void whenFindOrganizationWithCorrectParamThenReturnEntity(){ | ||
List<ConsumerEService> entity = | ||
consumerEServiceRepository.findByConsumerIdAndEServiceIdAndState( | ||
correctEservice, | ||
correctConsumer, | ||
correctState).collectList().block(); | ||
|
||
Assertions.assertFalse(entity.isEmpty()); | ||
Assertions.assertEquals(entity.get(0), getEntity()); | ||
} | ||
|
||
|
||
private ConsumerEService getEntity() { | ||
ConsumerEService entity = new ConsumerEService(); | ||
entity.setEserviceId(correctEservice); | ||
entity.setConsumerId(correctConsumer); | ||
entity.setState(correctState); | ||
entity.setTmstInsert(Timestamp.from(Instant.now())); | ||
return entity; | ||
} | ||
} |
74 changes: 57 additions & 17 deletions
74
.../java/it/pagopa/interop/signalhub/pull/service/repository/EServiceRepositoryImplTest.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
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