chore: fix localization tests, add annotations
parent
8575622c8a
commit
2391bc537f
6
pom.xml
6
pom.xml
|
@ -117,6 +117,12 @@
|
|||
<version>${javax.validation.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Flyway Module-->
|
||||
<dependency>
|
||||
<groupId>io.jooby</groupId>
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.github.polpetta.mezzotre.telegram.command;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import com.github.polpetta.mezzotre.helper.Loader;
|
||||
import com.github.polpetta.mezzotre.helper.TestConfig;
|
||||
import com.github.polpetta.mezzotre.i18n.LocalizedMessageFactory;
|
||||
|
@ -14,9 +11,6 @@ import com.pengrad.telegrambot.model.Update;
|
|||
import com.pengrad.telegrambot.request.BaseRequest;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
import io.ebean.Database;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
||||
|
@ -30,6 +24,12 @@ import org.testcontainers.containers.PostgreSQLContainer;
|
|||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@Tag("slow")
|
||||
@Tag("database")
|
||||
@Tag("velocity")
|
||||
|
@ -71,31 +71,33 @@ class StartIntegrationTest {
|
|||
@Test
|
||||
void shouldUpdateContextInTheDatabase() throws Exception {
|
||||
final TgChat tgChat = new TgChat(1111111L, new ChatContext());
|
||||
tgChat.setLocale("en-US");
|
||||
tgChat.save();
|
||||
|
||||
final Update update =
|
||||
gson.fromJson(
|
||||
"{\n"
|
||||
+ "\"update_id\":10000,\n"
|
||||
+ "\"message\":{\n"
|
||||
+ " \"date\":1441645532,\n"
|
||||
+ " \"chat\":{\n"
|
||||
+ " \"last_name\":\"Test Lastname\",\n"
|
||||
+ " \"id\":1111111,\n"
|
||||
+ " \"type\": \"private\",\n"
|
||||
+ " \"first_name\":\"Test Firstname\",\n"
|
||||
+ " \"username\":\"Testusername\"\n"
|
||||
+ " },\n"
|
||||
+ " \"message_id\":1365,\n"
|
||||
+ " \"from\":{\n"
|
||||
+ " \"last_name\":\"Test Lastname\",\n"
|
||||
+ " \"id\":1111111,\n"
|
||||
+ " \"first_name\":\"Test Firstname\",\n"
|
||||
+ " \"username\":\"Testusername\"\n"
|
||||
+ " },\n"
|
||||
+ " \"text\":\"/start\"\n"
|
||||
+ "}\n"
|
||||
+ "}",
|
||||
"""
|
||||
{
|
||||
"update_id":10000,
|
||||
"message":{
|
||||
"date":1441645532,
|
||||
"chat":{
|
||||
"last_name":"Test Lastname",
|
||||
"id":1111111,
|
||||
"type": "private",
|
||||
"first_name":"Test Firstname",
|
||||
"username":"Testusername"
|
||||
},
|
||||
"message_id":1365,
|
||||
"from":{
|
||||
"last_name":"Test Lastname",
|
||||
"id":1111111,
|
||||
"first_name":"Test Firstname",
|
||||
"username":"Testusername"
|
||||
},
|
||||
"text":"/start"
|
||||
}
|
||||
}""",
|
||||
Update.class);
|
||||
|
||||
final CompletableFuture<Optional<BaseRequest<?, ?>>> gotFuture = start.process(tgChat, update);
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.github.polpetta.mezzotre.telegram.command;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import com.github.polpetta.mezzotre.i18n.LocalizedMessageFactory;
|
||||
import com.github.polpetta.mezzotre.orm.model.TgChat;
|
||||
import com.github.polpetta.types.json.ChatContext;
|
||||
|
@ -10,18 +7,24 @@ import com.google.gson.Gson;
|
|||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.request.BaseRequest;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.parallel.Execution;
|
||||
import org.junit.jupiter.api.parallel.ExecutionMode;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
||||
import org.junit.jupiter.api.BeforeAll;import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.parallel.Execution;
|
||||
import org.junit.jupiter.api.parallel.ExecutionMode;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@Tag("velocity")
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
|
@ -52,33 +55,34 @@ class StartTest {
|
|||
@Test
|
||||
void shouldReceiveHelloIntroduction() throws Exception {
|
||||
final TgChat fakeChat = mock(TgChat.class);
|
||||
when(fakeChat.getLocale()).thenReturn("en");
|
||||
when(fakeChat.getLocale()).thenReturn("en-US");
|
||||
when(fakeChat.getChatContext()).thenReturn(new ChatContext());
|
||||
when(fakeChat.getId()).thenReturn(1111111L);
|
||||
|
||||
final Update update =
|
||||
gson.fromJson(
|
||||
"{\n"
|
||||
+ "\"update_id\":10000,\n"
|
||||
+ "\"message\":{\n"
|
||||
+ " \"date\":1441645532,\n"
|
||||
+ " \"chat\":{\n"
|
||||
+ " \"last_name\":\"Test Lastname\",\n"
|
||||
+ " \"id\":1111111,\n"
|
||||
+ " \"type\": \"private\",\n"
|
||||
+ " \"first_name\":\"Test Firstname\",\n"
|
||||
+ " \"username\":\"Testusername\"\n"
|
||||
+ " },\n"
|
||||
+ " \"message_id\":1365,\n"
|
||||
+ " \"from\":{\n"
|
||||
+ " \"last_name\":\"Test Lastname\",\n"
|
||||
+ " \"id\":1111111,\n"
|
||||
+ " \"first_name\":\"Test Firstname\",\n"
|
||||
+ " \"username\":\"Testusername\"\n"
|
||||
+ " },\n"
|
||||
+ " \"text\":\"/start\"\n"
|
||||
+ "}\n"
|
||||
+ "}",
|
||||
"""
|
||||
{
|
||||
"update_id":10000,
|
||||
"message":{
|
||||
"date":1441645532,
|
||||
"chat":{
|
||||
"last_name":"Test Lastname",
|
||||
"id":1111111,
|
||||
"type": "private",
|
||||
"first_name":"Test Firstname",
|
||||
"username":"Testusername"
|
||||
},
|
||||
"message_id":1365,
|
||||
"from":{
|
||||
"last_name":"Test Lastname",
|
||||
"id":1111111,
|
||||
"first_name":"Test Firstname",
|
||||
"username":"Testusername"
|
||||
},
|
||||
"text":"/start"
|
||||
}
|
||||
}""",
|
||||
Update.class);
|
||||
|
||||
final CompletableFuture<Optional<BaseRequest<?, ?>>> gotFuture =
|
||||
|
|
Loading…
Reference in New Issue