testes de integracao
parent
90fe1f1efc
commit
15c0e2932f
@ -1,23 +1,19 @@
|
|||||||
package br.com.ae3tecnologia.ms.tangerino;
|
package br.com.ae3tecnologia.ms.tangerino;
|
||||||
|
|
||||||
import org.springframework.boot.Banner;
|
import org.springframework.boot.Banner;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan(basePackages = {"br.com.ae3tecnologia.ms.tangerino"})
|
|
||||||
@EnableAutoConfiguration
|
|
||||||
public class TangerinoMSApplication extends SpringBootServletInitializer {
|
public class TangerinoMSApplication extends SpringBootServletInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||||
return builder.sources(getClass());
|
return builder.sources(getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SpringApplicationBuilder(TangerinoMSApplication.class).bannerMode(Banner.Mode.OFF).run(args);
|
new SpringApplicationBuilder(TangerinoMSApplication.class).bannerMode(Banner.Mode.OFF).run(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,82 @@
|
|||||||
|
package br.com.ae3tecnologia.ms.tangerino.controller;
|
||||||
|
|
||||||
|
import br.com.ae3tecnologia.ms.tangerino.model.PtoAdjustModel;
|
||||||
|
import br.com.ae3tecnologia.ms.tangerino.model.PtoEquipamentModel;
|
||||||
|
import br.com.ae3tecnologia.ms.tangerino.model.PtoEventModel;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
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.MockitoAnnotations;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@SpringBootTest
|
||||||
|
class PtoAdjustsRestControllerTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PtoAdjustController controller;
|
||||||
|
PtoEquipamentModel equipamento01;
|
||||||
|
PtoAdjustModel evento01;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
equipamento01 = new PtoEquipamentModel(
|
||||||
|
123,
|
||||||
|
"00004004330082159",
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
GregorianCalendar.getInstance().getTime(),
|
||||||
|
null,
|
||||||
|
"default",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
evento01 = new PtoAdjustModel(
|
||||||
|
123,
|
||||||
|
278,
|
||||||
|
4,
|
||||||
|
LocalDate.now(),
|
||||||
|
LocalDate.now(),
|
||||||
|
LocalTime.now().minusHours(10),
|
||||||
|
LocalTime.now(),
|
||||||
|
1,
|
||||||
|
"202304"
|
||||||
|
);
|
||||||
|
MockitoAnnotations.openMocks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mustObteinPunchAdjustTangerinoAPI() throws JsonProcessingException {
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
map.put("serialNumber", equipamento01.getSerialNumber());
|
||||||
|
map.put("page", 1);
|
||||||
|
map.put("size", 50);
|
||||||
|
map.put("registerType", 4);
|
||||||
|
List<PtoAdjustModel> ptoList = controller.gePunchTangerinoAPI(map);
|
||||||
|
Assertions.assertTrue(ptoList.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mustObteinLastNsrByExtractEventsAndReturnLastNsr() {
|
||||||
|
Integer lastNsr = controller.extractAdjustsAndReturnLastNsr(evento01.getNsr(), Arrays.asList(evento01));
|
||||||
|
Assertions.assertEquals(278, lastNsr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme
|
@ -0,0 +1,92 @@
|
|||||||
|
package br.com.ae3tecnologia.ms.tangerino.controller;
|
||||||
|
|
||||||
|
import br.com.ae3tecnologia.ms.tangerino.model.PtoAdjustModel;
|
||||||
|
import br.com.ae3tecnologia.ms.tangerino.model.PtoEquipamentModel;
|
||||||
|
import br.com.ae3tecnologia.ms.tangerino.model.PtoEventModel;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
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.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@SpringBootTest
|
||||||
|
class PtoExtractRestControllerTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PtoExtractRestController controller;
|
||||||
|
PtoEquipamentModel equipamento01;
|
||||||
|
PtoEventModel evento01;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
equipamento01 = new PtoEquipamentModel(
|
||||||
|
123,
|
||||||
|
"00004004330082159",
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
GregorianCalendar.getInstance().getTime(),
|
||||||
|
null,
|
||||||
|
"default",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
evento01 = new PtoEventModel(
|
||||||
|
1,
|
||||||
|
123,
|
||||||
|
1,
|
||||||
|
LocalDate.now(),
|
||||||
|
LocalTime.now(),
|
||||||
|
"123123123123",
|
||||||
|
123,
|
||||||
|
123,
|
||||||
|
false,
|
||||||
|
1,
|
||||||
|
"202304",
|
||||||
|
LocalDateTime.now()
|
||||||
|
);
|
||||||
|
MockitoAnnotations.openMocks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mustObteinPunchEventTangerinoAPI() throws JsonProcessingException {
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
map.put("serialNumber", equipamento01.getSerialNumber());
|
||||||
|
map.put("page", 1);
|
||||||
|
map.put("size", 50);
|
||||||
|
map.put("registerType", 3);
|
||||||
|
List<PtoEventModel> ptoEventModels = controller.gePunchTangerinoAPI(map, Arrays.asList());
|
||||||
|
Assertions.assertTrue(ptoEventModels.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mustObteinLastNsrByExtractEventsAndReturnLastNsr() {
|
||||||
|
Integer lastNsr = controller.extractEventsAndReturnLastNsr(evento01.getNsr(), Arrays.asList(evento01), equipamento01);
|
||||||
|
Assertions.assertEquals(0, lastNsr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mustObteinWatchesMock() {
|
||||||
|
List<PtoEquipamentModel> ptoEquipamentModels = controller.getWatches(false);
|
||||||
|
Assertions.assertNotEquals(null, ptoEquipamentModels);
|
||||||
|
Assertions.assertFalse(ptoEquipamentModels.isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme
|
Loading…
Reference in New Issue