1 package com.prueba.core.context.integration.liquibase.impl;
3 import static org.junit.Assert.*;
5 import java.util.ArrayList;
6 import java.util.HashMap;
10 import javax.sql.DataSource;
12 import org.junit.Test;
14 import com.prueba.core.context.integration.database.DataBaseAccess;
15 import com.prueba.core.context.integration.database.impl.DataBaseAccessImpl;
16 import com.prueba.core.context.integration.datasource.impl.DoDataSourceContext;
18 public class LiquibaseContextIntegrationTest {
19 private static final String CODE = "CODE";
20 private static final String NAME = "NAME";
21 private static final String SURNAME = "SURNAME";
22 private static final String PASSWORD = "PASSWORD";
23 private static final String APP_ROLE_CODE = "APPLICATION_ROLE_CODE";
26 public void whenLoadLiquibaseContextThenReturnSuccessFulQuery() {
27 final DataSource dataSource = DoDataSourceContext.getInstance().getDataSource();
28 final LiquibaseContext liquibaseContext = new LiquibaseContext(dataSource);
29 liquibaseContext.init();
31 final DataBaseAccess dataBaseAccess = new DataBaseAccessImpl();
32 final List<Map<String, String>> dataResult = dataBaseAccess.executeQuery("SELECT * FROM ACCOUNT",
35 final List<Map<String, String>> result = new ArrayList<>();
36 while (answer.next()) {
37 final Map<String, String> row = new HashMap<>();
38 row.put(CODE, answer.getString(CODE));
39 row.put(NAME, answer.getString(NAME));
40 row.put(SURNAME, answer.getString(SURNAME));
41 row.put(PASSWORD, answer.getString(PASSWORD));
42 row.put(APP_ROLE_CODE, answer.getString(APP_ROLE_CODE));
49 final String expectedCode = "GUMARTIN";
50 final String expectedName = "Gustavo";
51 final String expectedSurname = "Martin Morcuende";
52 final String expectedPassword = "lame";
53 final String expectedAppRoleCode = "ROLE_APP_ADMIN";
55 final Map<String, String> row = dataResult.get(0);
57 assertEquals(expectedCode, row.get(CODE));
58 assertEquals(expectedName, row.get(NAME));
59 assertEquals(expectedSurname, row.get(SURNAME));
60 assertEquals(expectedPassword, row.get(PASSWORD));
61 assertEquals(expectedAppRoleCode, row.get(APP_ROLE_CODE));