-
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.
Feature/integration test
- Loading branch information
Showing
7 changed files
with
234 additions
and
2 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
21 changes: 21 additions & 0 deletions
21
src/test/java/io/proyection/projection/Integration/Suite/ProjectionIntegrationSuite.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,21 @@ | ||
package io.proyection.projection.Integration.Suite; | ||
|
||
import org.junit.runner.RunWith; | ||
|
||
import cucumber.api.CucumberOptions; | ||
import cucumber.api.junit.Cucumber; | ||
|
||
@RunWith(Cucumber.class) | ||
@CucumberOptions( | ||
features = "src/test/resources", | ||
glue = {"io.proyection.projection.Integration.Test"}, | ||
plugin = { | ||
"pretty", | ||
"html:target/cucumber", | ||
"json:target/cucumber.json", | ||
"junit:target/cucumber_junit_report.xml" | ||
} | ||
) | ||
public class ProjectionIntegrationSuite { | ||
|
||
} |
142 changes: 142 additions & 0 deletions
142
src/test/java/io/proyection/projection/Integration/Test/TaskIntegrationTest.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,142 @@ | ||
package io.proyection.projection.Integration.Test; | ||
|
||
import static org.mockito.Mockito.doNothing; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.junit.Assert; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import cucumber.api.java.en.Given; | ||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
import io.proyection.projection.domain.Task; | ||
import io.proyection.projection.service.TaskService; | ||
|
||
public class TaskIntegrationTest { | ||
|
||
private final TaskService taskService = new TaskService(); | ||
private static Task task = new Task(); | ||
private String mensaje = ""; | ||
private String nombreTask = ""; | ||
|
||
@Mock | ||
private HttpServletResponse response; | ||
|
||
@Given("^despues de iniciar sesion en la aplicacion$") | ||
public void despues_de_iniciar_sesion_en_la_aplicacion() throws Throwable { | ||
MockitoAnnotations.initMocks(this); | ||
doNothing().when(response).sendRedirect("http://localhost:8080"); | ||
Assert.assertTrue(true); | ||
} | ||
|
||
@When("^hago click en el boton agregar tarea$") | ||
public void hago_click_en_el_boton_agregar_tarea() throws Throwable { | ||
MockitoAnnotations.initMocks(this); | ||
doNothing().when(response).sendRedirect("http://localhost:8080/tasks"); | ||
Assert.assertTrue(true); | ||
} | ||
|
||
@When("^en la nueva pantalla escribo en el campo Nombre el valor de \"([^\"]*)\"$") | ||
public void en_la_nueva_pantalla_escribo_en_el_campo_Nombre_el_valor_de(String arg1) throws Throwable { | ||
nombreTask = arg1; | ||
task.setSummary(nombreTask); | ||
Assert.assertTrue(true); } | ||
|
||
@When("^en la nueva pantalla escribo en el campo Descripcion el valor de \"([^\"]*)\"$") | ||
public void en_la_nueva_pantalla_escribo_en_el_campo_Descripcion_el_valor_de(String arg1) throws Throwable { | ||
nombreTask = arg1; | ||
task.setAcceptanceCriteria(nombreTask); | ||
Assert.assertTrue(true); } | ||
|
||
@When("^en la nueva pantalla escribo en el campo Fecha LÃmite el valor de \"([^\"]*)\"$") | ||
public void en_la_nueva_pantalla_escribo_en_el_campo_Fecha_LÃmite_el_valor_de(String arg1) throws Throwable { | ||
try { | ||
nombreTask = arg1; | ||
Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(nombreTask); | ||
task.setLimitDate(date1); | ||
} catch (Exception e) { | ||
System.out.println("Error: "+e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
@When("^presiono el boton de Guardar$") | ||
public void presiono_el_boton_de_Guardar() throws Throwable { | ||
try { | ||
task = taskService.saveOrUpdateTask(task, "usuario"); | ||
mensaje = "Se creo correctamente la Tarea"; | ||
Assert.assertTrue(true); | ||
} catch (Exception e) { | ||
mensaje = "Error: " + e.getMessage(); | ||
Assert.fail(mensaje); | ||
} | ||
} | ||
|
||
@Then("^el sistema me muestra el mensaje de: \"([^\"]*)\"$") | ||
public void el_sistema_me_muestra_el_mensaje_de(String arg1) throws Throwable { | ||
Assert.assertEquals(arg1, mensaje); | ||
} | ||
|
||
@When("^hago click sobre la tarea existente \"([^\"]*)\"$") | ||
public void hago_click_sobre_la_tarea_existente(String arg1) throws Throwable { | ||
Assert.assertTrue(true); | ||
} | ||
|
||
@When("^hago click en la opción actualizar tarea$") | ||
public void hago_click_en_la_opciÃ_n_actualizar_tarea() throws Throwable { | ||
try { | ||
task.setDone(true); | ||
Assert.assertTrue(true); | ||
} catch (Exception e) { | ||
System.out.print("Error actualizar: " + e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
@When("^presiono el boton de Actualizar$") | ||
public void presiono_el_boton_de_Actualizar() throws Throwable { | ||
try { | ||
taskService.saveOrUpdateTask(task, "usuario"); | ||
mensaje = "Se actualizo correctamente la Tarea"; | ||
Assert.assertTrue(true); | ||
} catch (Exception e) { | ||
mensaje = "Error: " + e.getMessage(); | ||
Assert.fail(mensaje); | ||
} | ||
} | ||
|
||
@When("^se muestra la pantalla de inicio$") | ||
public void se_muestra_la_pantalla_de_inicio() throws Throwable { | ||
// Write code here that turns the phrase above into concrete actions | ||
|
||
} | ||
|
||
@Then("^el sistema me muestra un listado con las tareas existentes$") | ||
public void el_sistema_me_muestra_un_listado_con_las_tareas_existentes() throws Throwable { | ||
try { | ||
List<Task> lista = (List<Task>) taskService.findAllTask(task.getUsername()); | ||
Assert.assertTrue(lista.size()>=0); | ||
} catch (Exception e) { | ||
System.out.print("Error actualizar: " + e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
@When("^hago click en la opción eliminar tarea$") | ||
public void hago_click_en_la_opciÃ_n_eliminar_tarea() throws Throwable { | ||
try { | ||
taskService.deleteTaskByIdentifier(task.getId(), task.getUsername()); | ||
mensaje = "Se elimino correctamente la Tarea"; | ||
Assert.assertTrue(true); | ||
} catch (Exception e) { | ||
mensaje = "Error: " + e.getMessage(); | ||
Assert.fail(mensaje); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/test/java/io/proyection/projection/Integration/Test/UserIntegrationTest.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,70 @@ | ||
package io.proyection.projection.Integration.Test; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.junit.Assert; | ||
import org.mockito.Mock; | ||
|
||
import cucumber.api.java.en.Given; | ||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
import io.proyection.projection.domain.User; | ||
import io.proyection.projection.service.UserService; | ||
|
||
public class UserIntegrationTest { | ||
|
||
private final UserService userService = new UserService(); | ||
private static User user = new User(); | ||
private String mensaje = ""; | ||
private String nombre = ""; | ||
|
||
@Mock | ||
private HttpServletResponse response; | ||
|
||
@Given("^user name is \"([^\"]*)\"$") | ||
public void user_name_is(String arg1) throws Throwable { | ||
user.setUsername(nombre); | ||
user.setPassword("test"); | ||
Assert.assertTrue(user.getUsername() == ""); | ||
} | ||
|
||
@When("^post method save user is \"([^\"]*)\"$") | ||
public void post_method_save_user_is(String arg1) throws Throwable { | ||
try { | ||
userService.saveUser(user); | ||
mensaje = "name is compulsory"; | ||
Assert.assertTrue(true); | ||
} catch (Exception e) { | ||
System.out.println("Error: "+e.getMessage()); | ||
} | ||
} | ||
|
||
@Then("^the user recieves the message \"([^\"]*)\"$") | ||
public void the_user_recieves_the_message(String arg1) throws Throwable { | ||
Assert.assertTrue(mensaje == arg1); | ||
} | ||
|
||
@Given("^user password is \"([^\"]*)\"$") | ||
public void user_password_is(String arg1) throws Throwable { | ||
user.setPassword(nombre); | ||
user.setUsername("test00"); | ||
Assert.assertTrue(user.getPassword() == ""); | ||
} | ||
|
||
@When("^post method save users is \"([^\"]*)\"$") | ||
public void post_method_save_users_is(String arg1) throws Throwable { | ||
try { | ||
userService.saveUser(user); | ||
mensaje = "password is compulsory"; | ||
Assert.assertTrue(true); | ||
} catch (Exception e) { | ||
System.out.println("Error: "+e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
@Then("^the user recieves the messagesito \"([^\"]*)\"$") | ||
public void the_user_recieves_the_messagesito(String arg1) throws Throwable { | ||
Assert.assertTrue(mensaje == arg1); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.