# Pasos

ejbmoordb esta optimizado para trabajar con proyectos JavaEE8/jakartaEE

**Los pasos básicos son:**

1. Cree un proyecto ejb
2. Cree un proyecto web
3. En el proyecto Web cree las clases de test
4. Ordene la secuencia de ejecución
5. El ultimo test debe invocar el mètodo unitTest.terminate() para generación de los reportes del test sin necesidad de detener el servidor de aplicaciones.
6. Puede crear un Uber Jar y ejecutarlo desde consola.
7. Recuerde iniciar mongodb
8. Si utiliza NetBeans IDE instale el plugin de Payara Micro

## Un Test Simple

Usar las anotaciones

* @Startup
* @Singleton
* @DependsOn("TestEnvironment")
* @Test
* @Report(path = "/home/avbravo/Descargas/")

## Implementar

* implements ITest
* usar el método nameOfMethod() para enviar el nombre del método.

## Inyectar

@Inject

```
UnitTest unitTest;
```

## Métodos

```java
 @PostConstruct
    @Override
    public void init() {
        unitTest.start(BodegaTest.class);

//metodos

    }
```

```java
 @PreDestroy
    @Override
    public void destroy() {
        unitTest.end(BodegaTest.class);
    }
```

```java
@Startup
@Singleton
@DependsOn("TestEnvironment")
@Test
@Report(path = "/home/avbravo/Descargas/")
public class BodegaTest implements ITest{
  @Inject
    UnitTest unitTest;
    @Inject
    BodegaRepository bodegaRepository;

    @PostConstruct
    public void init() {
        unitTest.start(BodegaTest.class);

        save();
        findAll();

    }

    @Test
    private void save() {
        try {

            //Mock
            Bodega bodega = new Bodega();
            bodega.setIdbodega("bodega-test");
            bodega.setDireccion("Panama");
            bodega.setTelefono("(507)");
            //User info es una clase que usa el framework para guardar referencias
            //de usuarios
            List<UserInfo> list = new ArrayList<>();
            bodega.setUserInfo(list);
            bodega.setActivo("si");

            unitTest.assertEquals(nameOfMethod(), true,bodegaRepository.save(bodega));
        } catch (Exception e) {
            System.out.println(nameOfMethod() + e.getLocalizedMessage());
        }

    }

    @Test
    private void findAll() {

    unitTest.assertNotEquals(nameOfMethod(), 0, bodegaRepository.findAll().size());


    }

    @PreDestroy
    @Override
    public void destroy() {
        unitTest.end(BodegaTest.class);
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/jmoordbunit/overview/proyectos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
