-
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.
Adapted method to get supply data from Datadis get data from supplies…
… from owner and from authorized supplies
- Loading branch information
1 parent
c0eecc9
commit cf3bc18
Showing
3 changed files
with
74 additions
and
4 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
54 changes: 54 additions & 0 deletions
54
...conluz/infrastructure/admin/supply/get/GetSupplyRepositoryDatadisRestIntegrationTest.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,54 @@ | ||
package org.lucoenergia.conluz.infrastructure.admin.supply.get; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.lucoenergia.conluz.domain.admin.supply.DatadisSupply; | ||
import org.lucoenergia.conluz.domain.admin.user.User; | ||
import org.lucoenergia.conluz.infrastructure.consumption.datadis.DatadisConfigRepository; | ||
import org.lucoenergia.conluz.infrastructure.consumption.datadis.config.DatadisConfigEntity; | ||
import org.lucoenergia.conluz.infrastructure.shared.BaseIntegrationTest; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@Disabled("These tests should not be included in a CI pipeline because connects with datadis.es, so, needs real data.") | ||
@Transactional | ||
class GetSupplyRepositoryDatadisRestIntegrationTest extends BaseIntegrationTest { | ||
|
||
@Autowired | ||
private GetSupplyRepositoryDatadisRest getSupplyRepositoryDatadisRest; | ||
@Autowired | ||
private DatadisConfigRepository datadisConfigRepository; | ||
|
||
@Test | ||
void testGetSuppliesByUser() { | ||
|
||
// Set username and password you want to user for testing here | ||
final String username = "username"; | ||
final String password = "password"; | ||
|
||
// Save Datadis config on the DB | ||
final DatadisConfigEntity config = new DatadisConfigEntity(); | ||
config.setId(UUID.randomUUID()); | ||
config.setUsername(username); | ||
config.setPassword(password); | ||
datadisConfigRepository.save(config); | ||
|
||
User user = new User.Builder() | ||
.id(UUID.randomUUID()) | ||
.personalId("personalId") | ||
.number(1) | ||
.fullName("John Doe") | ||
.email("username@email.com") | ||
.enabled(true) | ||
.build(); | ||
|
||
List<DatadisSupply> suppliesByUser = getSupplyRepositoryDatadisRest.getSuppliesByUser(user); | ||
|
||
assertEquals(1, suppliesByUser.size()); | ||
} | ||
} |