From 7a842c510ab593e0e8b6b32e02fb13afd74a2efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Pomyka=C5=82a?= Date: Fri, 8 Sep 2023 13:50:16 +0200 Subject: [PATCH] Polishing --- junit/mock-server/test.json | 2 +- .../cli/client/ObjectMapperSingleton.java | 2 +- .../cli/client/SimpleLocalizeClient.java | 8 +- .../cli/client/dto/DownloadRequest.java | 2 +- .../cli/client/dto/FileToUpload.java | 2 +- .../cli/client/dto/UploadRequest.java | 2 +- .../client/dto/proxy/DownloadableFile.java | 2 +- .../cli/command/DownloadCommand.java | 2 +- .../cli/command/StatusCommand.java | 2 +- .../cli/command/UploadCommand.java | 4 +- .../simplelocalize/cli/io/FileListReader.java | 2 +- .../io/simplelocalize/cli/io/JsonReader.java | 4 +- .../cli/SimplelocalizeCliCommandTest.java | 149 +++++++++++------- .../cli/client/SimpleLocalizeClientTest.java | 30 +++- .../cli/client/dto/UploadRequestTest.java | 12 +- .../cli/command/DownloadCommandTest.java | 12 +- .../cli/command/UploadCommandTest.java | 8 +- .../cli/util/FileListReaderTest.java | 58 +++---- .../cli/util/TestLogEventFactory.java | 19 +++ 19 files changed, 195 insertions(+), 127 deletions(-) diff --git a/junit/mock-server/test.json b/junit/mock-server/test.json index 35a91eb..0bbce95 100644 --- a/junit/mock-server/test.json +++ b/junit/mock-server/test.json @@ -14,4 +14,4 @@ } catch (e) { } -

Translation management
for software projects

Elegant and simple web-based translation editor. It helps small and growing teams save time on handling localization files and translation strings.

No credit card required 14-day free trial Tracking-free service
online translation editor interface
  • Auto-translation
  • Screenshots
  • Acceptance statuses
  • Quick search
  • Translation history
  • File export & import
  • Customizable view
  • Key descriptions
  • Namespaces support
  • Side-by-Side view
  • Spreadsheet view
  • Text summary

How it works?

Import translations to our editor, auto-translate them to other languages.
Download translation files or host translations in the cloud with one click.

how it works

Why SimpleLocalize?

Most translation editors are overkill for most teams. SimpleLocalize is easy
to use and understand with no training or prior experience.

Simple and customizable

SimpleLocalize is easy to get started with and focuses on the features that you and your client need the most. You can customize the editor to your needs choosing from a variety of translation editor options.

Flat pricing

No hidden costs at any scale. SimpleLocalize offers a simple and affordable plans for you and your projects. Within easy integration options and intuitive translation editor, it creates a wonderful selection.

Team members

Every paid plan comes with a number of users you can add to your project. You don't need to worry about number of users as the price does not increase with every user.

Auto-translation included

Every paid plan comes with a number of auto-translation characters that are added to your account every month. You can use them to translate your project without any additional costs. You can increase the limit at any time.

Tools for Developers

SimpleLocalize offers a command-line tool, REST API and Webhooks for developers to easily integrate their projects no matter which plan you choose. It enables you to make automations to synchronize translations with your projects.

Alternative translations

SimpleLocalize is the only service that offers customer-specific translations, which allows you to adjust translation for one customer without affecting base translations.

Auto-translate texts

Select the language which you want to translate and hit 'Start auto-translate' button. Done! Your application is now translated into the language you selected. You can use 120 languages from Google Translate or DeepL to translate your application in just a few seconds!

Learn more about auto-translation
translate web application with google translate or deepl

Translation Hosting

Every project has its space on our servers, which are covered with a CDN layer. The CDN is the fastest possible way to deliver translations anywhere, anytime for you, your users, and developers.

Translation hosting
localization for react and translations hosting

Import and export
translations

You can export translations into an any available file format or import new files to merge translations into existing ones.

How to import spreadsheet with translations
spreadsheet with translations

Trusted by many

Our Translation Hosting is used by over 100 million people every month.

simplelocalize cloudflare request count
  • Expo
  • FormatJS
  • Swift language
  • Unity
  • Excel file
  • Ionic
  • Module exports
  • macOS
  • Cordova
  • GitHub
  • TypeScript
  • Resource XML
  • Android strings
  • GitHub
  • FormatJS CLI
  • React Native
  • Single Language JSON
  • CSV file
  • i18next
  • React
  • Spring Boot
  • Java language
  • Android
  • iOS
  • next-i18next
  • Kotlin language
  • [object Object]
  • Google Translate
  • Multi Language JSON
  • GatsbyJS
  • Java Properties
  • Vue
  • Localizable strings
  • Laravel
  • Zapier
  • Webhooks
  • next-translate
  • JavaScript
  • Excel
  • PO/POT file
  • SimpleLocalize JSON
  • FormatJS CLI
  • NodeJS
  • Angular
  • Slack
  • Yaml file
  • PHP Array
  • Jekyll
  • macOS
  • Android
  • PHP Array
  • Laravel
  • SimpleLocalize JSON
  • GitHub
  • Java language
  • Single Language JSON
  • Vue
  • Angular
  • iOS
  • CSV file
  • i18next
  • Unity
  • Swift language
  • NodeJS
  • Webhooks
  • Cordova
  • Jekyll
  • FormatJS CLI
  • JavaScript
  • Excel file
  • FormatJS CLI
  • [object Object]
  • PO/POT file
  • GatsbyJS
  • Kotlin language
  • Android strings
  • React Native
  • GitHub
  • Excel
  • Java Properties
  • Zapier
  • Yaml file
  • Multi Language JSON
  • Module exports
  • Resource XML
  • Google Translate
  • FormatJS
  • Spring Boot
  • Slack
  • Localizable strings
  • next-translate
  • Expo
  • TypeScript
  • next-i18next
  • React
  • Ionic
  • Swift language
  • TypeScript
  • macOS
  • next-translate
  • Spring Boot
  • Unity
  • iOS
  • Java Properties
  • Cordova
  • CSV file
  • Vue
  • Angular
  • FormatJS
  • GitHub
  • Yaml file
  • Module exports
  • next-i18next
  • Android
  • Excel file
  • FormatJS CLI
  • SimpleLocalize JSON
  • Laravel
  • i18next
  • GitHub
  • PO/POT file
  • Webhooks
  • Android strings
  • PHP Array
  • Multi Language JSON
  • NodeJS
  • Expo
  • Slack
  • Jekyll
  • Google Translate
  • Localizable strings
  • Resource XML
  • React Native
  • Kotlin language
  • Ionic
  • Zapier
  • Java language
  • Excel
  • [object Object]
  • GatsbyJS
  • FormatJS CLI
  • JavaScript
  • React
  • Single Language JSON

Integrated with your favourite tools

Have you already integrated i18n library? You can now connect SimpleLocalize without doing much changes in the application code. We don't bound you with our own 'yet another i18n library'.

Browse integrations

Latest news

Check out our latest blog posts and stay up to date with SimpleLocalize

Translation Hosting: How to update translations automatically?

Translation Hosting: How to update translations automatically?

Kinga WojciechowskabyKinga Wojciechowska7 min read

Save time with automatic translation updates. Try SimpleLocalize Translation Hosting to keep your app's translations up to date effortlessly in any environment.

Continue reading
How to auto-translate JSON files

How to auto-translate JSON files

Kinga WojciechowskabyKinga Wojciechowska5 min read

Simplify your localization process by learning how to auto-translate JSON files with SimpleLocalize's translation editor and auto-translation feature.

Continue reading
How to get started with a TMS: An introduction to SimpleLocalize

How to get started with a TMS: An introduction to SimpleLocalize

Kinga WojciechowskabyKinga Wojciechowska9 min read

Start using a TMS for localization of your software project. Learn how to get started and manage your translations.

Continue reading
Ready to say
|

Greet your customers
in their mother language

Start 14-day trial
No credit card required
country flags
\ No newline at end of file +

Translation management
for software projects

Elegant and simple web-based translation editor. It helps small and growing teams save time on handling localization files and translation strings.

No credit card required 14-day free trial Tracking-free service
online translation editor interface
  • Auto-translation
  • Screenshots
  • Acceptance statuses
  • Quick search
  • Translation history
  • File export & import
  • Customizable view
  • Key descriptions
  • Namespaces support
  • Side-by-Side view
  • Spreadsheet view
  • Text summary

How it works?

Import translations to our editor, auto-translate them to other languages.
Download translation files or host translations in the cloud with one click.

how it works

Why SimpleLocalize?

Most translation editors are overkill for most teams. SimpleLocalize is easy
to use and understand with no training or prior experience.

Simple and customizable

SimpleLocalize is easy to get started with and focuses on the features that you and your client need the most. You can customize the editor to your needs choosing from a variety of translation editor options.

Flat pricing

No hidden costs at any scale. SimpleLocalize offers a simple and affordable plans for you and your projects. Within easy integration options and intuitive translation editor, it creates a wonderful selection.

Team members

Every paid plan comes with a number of users you can add to your project. You don't need to worry about number of users as the price does not increase with every user.

Auto-translation included

Every paid plan comes with a number of auto-translation characters that are added to your account every month. You can use them to translate your project without any additional costs. You can increase the limit at any time.

Tools for Developers

SimpleLocalize offers a command-line tool, REST API and Webhooks for developers to easily integrate their projects no matter which plan you choose. It enables you to make automations to synchronize translations with your projects.

Alternative translations

SimpleLocalize is the only service that offers customer-specific translations, which allows you to adjust translation for one customer without affecting base translations.

Auto-translate texts

Select the language which you want to translate and hit 'Start auto-translate' button. Done! Your application is now translated into the language you selected. You can use 120 languages from Google Translate or DeepL to translate your application in just a few seconds!

Learn more about auto-translation
translate web application with google translate or deepl

Translation Hosting

Every project has its space on our servers, which are covered with a CDN layer. The CDN is the fastest possible way to deliver translations anywhere, anytime for you, your users, and developers.

Translation hosting
localization for react and translations hosting

Import and export
translations

You can export translations into an any available file format or import new files to merge translations into existing ones.

How to import spreadsheet with translations
spreadsheet with translations

Trusted by many

Our Translation Hosting is used by over 100 million people every month.

simplelocalize cloudflare request count
  • Slack
  • Android
  • Angular
  • Jekyll
  • Java language
  • PHP Array
  • Multi Language JSON
  • iOS
  • Java Properties
  • Vue
  • Kotlin language
  • [object Object]
  • Spring Boot
  • Laravel
  • React Native
  • Swift language
  • Expo
  • i18next
  • Ionic
  • macOS
  • GitHub
  • FormatJS CLI
  • FormatJS CLI
  • Single Language JSON
  • next-i18next
  • Zapier
  • NodeJS
  • Resource XML
  • Cordova
  • Localizable strings
  • Excel file
  • FormatJS
  • Webhooks
  • SimpleLocalize JSON
  • Google Translate
  • React
  • JavaScript
  • TypeScript
  • GitHub
  • next-translate
  • GatsbyJS
  • Unity
  • Module exports
  • Android strings
  • PO/POT file
  • Yaml file
  • CSV file
  • Excel
  • Jekyll
  • TypeScript
  • Slack
  • GitHub
  • FormatJS
  • Java language
  • Kotlin language
  • Android strings
  • next-translate
  • FormatJS CLI
  • Excel file
  • Unity
  • Google Translate
  • PO/POT file
  • CSV file
  • FormatJS CLI
  • Laravel
  • NodeJS
  • next-i18next
  • iOS
  • Excel
  • Swift language
  • Single Language JSON
  • i18next
  • Yaml file
  • Module exports
  • macOS
  • [object Object]
  • Expo
  • GitHub
  • PHP Array
  • Webhooks
  • Android
  • Spring Boot
  • JavaScript
  • SimpleLocalize JSON
  • Resource XML
  • GatsbyJS
  • React
  • Cordova
  • Java Properties
  • Localizable strings
  • Angular
  • Ionic
  • Vue
  • Zapier
  • Multi Language JSON
  • React Native
  • Laravel
  • React
  • Ionic
  • [object Object]
  • Slack
  • Multi Language JSON
  • Zapier
  • iOS
  • Google Translate
  • Java Properties
  • GatsbyJS
  • Resource XML
  • Android
  • Excel
  • Excel file
  • GitHub
  • Java language
  • React Native
  • FormatJS CLI
  • macOS
  • PHP Array
  • GitHub
  • Unity
  • i18next
  • Swift language
  • Android strings
  • Cordova
  • NodeJS
  • Angular
  • Single Language JSON
  • CSV file
  • SimpleLocalize JSON
  • Yaml file
  • JavaScript
  • TypeScript
  • next-translate
  • Jekyll
  • PO/POT file
  • Spring Boot
  • Localizable strings
  • Kotlin language
  • Webhooks
  • Vue
  • FormatJS
  • next-i18next
  • Module exports
  • Expo
  • FormatJS CLI

Integrated with your favourite tools

Have you already integrated i18n library? You can now connect SimpleLocalize without doing much changes in the application code. We don't bound you with our own 'yet another i18n library'.

Browse integrations

Latest news

Check out our latest blog posts and stay up to date with SimpleLocalize

How to share translation keys across multiple apps?

How to share translation keys across multiple apps?

Kinga WojciechowskabyKinga Wojciechowska4 min read

Easily manage translations across multiple apps with SimpleLocalize's key merging feature. Save time and maintain consistency!

Continue reading
Translation Hosting: How to update translations automatically?

Translation Hosting: How to update translations automatically?

Kinga WojciechowskabyKinga Wojciechowska7 min read

Save time with automatic translation updates. Try SimpleLocalize Translation Hosting to keep your app's translations up to date effortlessly in any environment.

Continue reading
How to auto-translate JSON files

How to auto-translate JSON files

Kinga WojciechowskabyKinga Wojciechowska5 min read

Simplify your localization process by learning how to auto-translate JSON files with SimpleLocalize's translation editor and auto-translation feature.

Continue reading
Ready to say
|

Greet your customers
in their mother language

Start 14-day trial
No credit card required
country flags
\ No newline at end of file diff --git a/src/main/java/io/simplelocalize/cli/client/ObjectMapperSingleton.java b/src/main/java/io/simplelocalize/cli/client/ObjectMapperSingleton.java index 53fc316..ae32c81 100644 --- a/src/main/java/io/simplelocalize/cli/client/ObjectMapperSingleton.java +++ b/src/main/java/io/simplelocalize/cli/client/ObjectMapperSingleton.java @@ -6,7 +6,7 @@ public class ObjectMapperSingleton { - private static ObjectMapper INSTANCE = null; + private static ObjectMapper INSTANCE = null; //NOSONAR private ObjectMapperSingleton() { diff --git a/src/main/java/io/simplelocalize/cli/client/SimpleLocalizeClient.java b/src/main/java/io/simplelocalize/cli/client/SimpleLocalizeClient.java index 21c3542..f1a4f93 100644 --- a/src/main/java/io/simplelocalize/cli/client/SimpleLocalizeClient.java +++ b/src/main/java/io/simplelocalize/cli/client/SimpleLocalizeClient.java @@ -182,12 +182,12 @@ private void throwOnError(HttpResponse httpResponse) private String safeCastHttpBodyToString(Object responseBody) { - if (responseBody instanceof byte[]) + if (responseBody instanceof byte[] responseBodyBytes) { - return new String((byte[]) responseBody); - } else if (responseBody instanceof String) + return new String(responseBodyBytes); + } else if (responseBody instanceof String responseBodyString) { - return (String) responseBody; + return responseBodyString; } return ""; } diff --git a/src/main/java/io/simplelocalize/cli/client/dto/DownloadRequest.java b/src/main/java/io/simplelocalize/cli/client/dto/DownloadRequest.java index 303764e..ba45e06 100644 --- a/src/main/java/io/simplelocalize/cli/client/dto/DownloadRequest.java +++ b/src/main/java/io/simplelocalize/cli/client/dto/DownloadRequest.java @@ -16,7 +16,7 @@ private DownloadRequestBuilder() { } - public static DownloadRequestBuilder Builder() + public static DownloadRequestBuilder builder() { return new DownloadRequestBuilder(); } diff --git a/src/main/java/io/simplelocalize/cli/client/dto/FileToUpload.java b/src/main/java/io/simplelocalize/cli/client/dto/FileToUpload.java index 3836f52..b4d7929 100644 --- a/src/main/java/io/simplelocalize/cli/client/dto/FileToUpload.java +++ b/src/main/java/io/simplelocalize/cli/client/dto/FileToUpload.java @@ -16,7 +16,7 @@ private FileToUploadBuilder() { } - public static FileToUploadBuilder Builder() + public static FileToUploadBuilder builder() { return new FileToUploadBuilder(); } diff --git a/src/main/java/io/simplelocalize/cli/client/dto/UploadRequest.java b/src/main/java/io/simplelocalize/cli/client/dto/UploadRequest.java index 82928a1..456f741 100644 --- a/src/main/java/io/simplelocalize/cli/client/dto/UploadRequest.java +++ b/src/main/java/io/simplelocalize/cli/client/dto/UploadRequest.java @@ -26,7 +26,7 @@ private UploadFileRequestBuilder() { } - public static UploadFileRequestBuilder Builder() + public static UploadFileRequestBuilder builder() { return new UploadFileRequestBuilder(); } diff --git a/src/main/java/io/simplelocalize/cli/client/dto/proxy/DownloadableFile.java b/src/main/java/io/simplelocalize/cli/client/dto/proxy/DownloadableFile.java index 9f06ff6..4cfdff6 100644 --- a/src/main/java/io/simplelocalize/cli/client/dto/proxy/DownloadableFile.java +++ b/src/main/java/io/simplelocalize/cli/client/dto/proxy/DownloadableFile.java @@ -16,7 +16,7 @@ private DownloadableFileBuilder() { } - public static DownloadableFileBuilder Builder() + public static DownloadableFileBuilder builder() { return new DownloadableFileBuilder(); } diff --git a/src/main/java/io/simplelocalize/cli/command/DownloadCommand.java b/src/main/java/io/simplelocalize/cli/command/DownloadCommand.java index 2964d8c..891ca10 100644 --- a/src/main/java/io/simplelocalize/cli/command/DownloadCommand.java +++ b/src/main/java/io/simplelocalize/cli/command/DownloadCommand.java @@ -43,7 +43,7 @@ public void invoke() throws IOException, InterruptedException downloadOptions.add("SPLIT_BY_LANGUAGES"); } - DownloadRequest downloadRequest = DownloadRequest.DownloadRequestBuilder.Builder() + DownloadRequest downloadRequest = DownloadRequest.DownloadRequestBuilder.builder() .withFormat(downloadFormat) .withOptions(downloadOptions) .withCustomerId(customerId) diff --git a/src/main/java/io/simplelocalize/cli/command/StatusCommand.java b/src/main/java/io/simplelocalize/cli/command/StatusCommand.java index dc74d77..5f87f1c 100644 --- a/src/main/java/io/simplelocalize/cli/command/StatusCommand.java +++ b/src/main/java/io/simplelocalize/cli/command/StatusCommand.java @@ -32,7 +32,7 @@ public void invoke() throws IOException, InterruptedException Float translated = Objects.requireNonNullElse(translatedNullable, 0.0f); Float translatedPercentage = translated * 100; String translatedPercentageFormatted = String.format("%.0f", translatedPercentage); - log.info("Translated: {}", translatedPercentageFormatted + "%"); + log.info("Translated: {}%", translatedPercentageFormatted); log.info("Languages: {}", json.read("$.data.languages[*].key").toString()); log.info("Environments: {}", json.read("$.data.environments[*].key").toString()); log.info("Namespaces: {}", json.read("$.data.namespaces[*].name").toString()); diff --git a/src/main/java/io/simplelocalize/cli/command/UploadCommand.java b/src/main/java/io/simplelocalize/cli/command/UploadCommand.java index c05897e..011844c 100644 --- a/src/main/java/io/simplelocalize/cli/command/UploadCommand.java +++ b/src/main/java/io/simplelocalize/cli/command/UploadCommand.java @@ -15,7 +15,7 @@ import java.util.List; import java.util.Optional; -import static io.simplelocalize.cli.client.dto.UploadRequest.UploadFileRequestBuilder.Builder; +import static io.simplelocalize.cli.client.dto.UploadRequest.UploadFileRequestBuilder.builder; public class UploadCommand implements CliCommand { @@ -93,7 +93,7 @@ public void invoke() throws IOException, InterruptedException String uploadFormat = configuration.getUploadFormat(); String customerId = configuration.getCustomerId(); List uploadOptions = configuration.getUploadOptions(); - UploadRequest uploadRequest = Builder() + UploadRequest uploadRequest = builder() .withPath(fileToUpload.path()) .withLanguageKey(requestLanguageKey) .withNamespace(fileToUpload.namespace()) diff --git a/src/main/java/io/simplelocalize/cli/io/FileListReader.java b/src/main/java/io/simplelocalize/cli/io/FileListReader.java index 09855c9..d5b7ec2 100644 --- a/src/main/java/io/simplelocalize/cli/io/FileListReader.java +++ b/src/main/java/io/simplelocalize/cli/io/FileListReader.java @@ -41,7 +41,7 @@ private List findMatchingFiles(Path parentDirectory, String patter { String lang = getGroupOrNull("lang", matcher); String ns = getGroupOrNull("ns", matcher); - return FileToUpload.FileToUploadBuilder.Builder() + return FileToUpload.FileToUploadBuilder.builder() .withLanguage(lang) .withNamespace(ns) .withPath(file).build(); diff --git a/src/main/java/io/simplelocalize/cli/io/JsonReader.java b/src/main/java/io/simplelocalize/cli/io/JsonReader.java index 65b6f0e..9fd4c7c 100644 --- a/src/main/java/io/simplelocalize/cli/io/JsonReader.java +++ b/src/main/java/io/simplelocalize/cli/io/JsonReader.java @@ -22,9 +22,9 @@ public JsonReader() public DocumentContext read(String json) { - Configuration mappingConfiguration = Configuration.defaultConfiguration() + Configuration jsonPathConfiguration = Configuration.defaultConfiguration() .jsonProvider(this.jsonProvider) .mappingProvider(this.mappingConfiguration); - return JsonPath.parse(json, mappingConfiguration); + return JsonPath.parse(json, jsonPathConfiguration); } } diff --git a/src/test/java/io/simplelocalize/cli/SimplelocalizeCliCommandTest.java b/src/test/java/io/simplelocalize/cli/SimplelocalizeCliCommandTest.java index 7e86d69..2ae7691 100644 --- a/src/test/java/io/simplelocalize/cli/SimplelocalizeCliCommandTest.java +++ b/src/test/java/io/simplelocalize/cli/SimplelocalizeCliCommandTest.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.mockserver.integration.ClientAndServer.startClientAndServer; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; @@ -45,7 +46,7 @@ public static void stopServer() @Test void extract() { - // given & when & then + // given mockServer.when(request() .withMethod("POST") .withPath("/cli/v1/keys") @@ -58,14 +59,17 @@ void extract() .withBody("{ 'msg': 'OK', data: { uniqueKeysProcessed: 1, processedWithWarnings: false } }") .withDelay(TimeUnit.MILLISECONDS, 200)); - sut.extract("my-api-key", "yahoo/react-intl", "./", MOCK_SERVER_BASE_URL); + //when + assertDoesNotThrow(() -> { + sut.extract("my-api-key", "yahoo/react-intl", "./", MOCK_SERVER_BASE_URL); + }); } @Test - void sync() throws IOException + void sync() { - // given & when & then + // given mockServer.when(request() .withMethod("POST") .withPath("/cli/v2/upload") @@ -93,25 +97,29 @@ void sync() throws IOException .withDelay(TimeUnit.MILLISECONDS, 200) ); - sut.sync( - "my-api-key", - "./junit/mock-server/test.json", - "multi-language-json", - List.of(), - "./junit/mock-server/test.json", - "java-properties", - List.of("SPLIT_BY_NAMESPACES"), - null, - null, - null, - MOCK_SERVER_BASE_URL - ); + + //when + assertDoesNotThrow(() -> { + sut.sync( + "my-api-key", + "./junit/mock-server/test.json", + "multi-language-json", + List.of(), + "./junit/mock-server/test.json", + "java-properties", + List.of("SPLIT_BY_NAMESPACES"), + null, + null, + null, + MOCK_SERVER_BASE_URL + ); + }); } @Test - void upload() throws IOException + void upload() { - // given & when & then + // given mockServer.when(request() .withMethod("POST") .withPath("/cli/v2/upload") @@ -126,24 +134,27 @@ void upload() throws IOException .withDelay(TimeUnit.MILLISECONDS, 200) ); - sut.upload( - "my-api-key", - "./junit/mock-server/test.json", - "multi-language-json", - false, - false, - false, - List.of("SPLIT_BY_NAMESPACES"), - null, - null, - MOCK_SERVER_BASE_URL - ); + //when + assertDoesNotThrow(() -> { + sut.upload( + "my-api-key", + "./junit/mock-server/test.json", + "multi-language-json", + false, + false, + false, + List.of("SPLIT_BY_NAMESPACES"), + null, + null, + MOCK_SERVER_BASE_URL + ); + }); } @Test void download() { - // given & when & then + // given mockServer.when(request() .withMethod("GET") .withPath("/cli/v2/download") @@ -158,22 +169,25 @@ void download() .withDelay(TimeUnit.MILLISECONDS, 200) ); - sut.download( - "my-api-key", - "./junit/mock-server/test.json", - "java-properties", - List.of("SPLIT_BY_NAMESPACES"), - null, - null, - null, - MOCK_SERVER_BASE_URL - ); + //when + assertDoesNotThrow(() -> { + sut.download( + "my-api-key", + "./junit/mock-server/test.json", + "java-properties", + List.of("SPLIT_BY_NAMESPACES"), + null, + null, + null, + MOCK_SERVER_BASE_URL + ); + }); } @Test void pull() throws IOException { - // given & when & then + // given String path = SimplelocalizeCliCommandTest.class.getClassLoader().getResource("mock-api-responses/fetch-project-empty-hosting-resources.json").getPath(); String content = Files.readString(Path.of(path), StandardCharsets.UTF_8); mockServer.when(request() @@ -188,15 +202,16 @@ void pull() throws IOException .withDelay(TimeUnit.MILLISECONDS, 200) ); - - sut.pull("my-api-key", "./my-path", "latest", null, MOCK_SERVER_BASE_URL); - + //when + assertDoesNotThrow(() -> { + sut.pull("my-api-key", "./my-path", "latest", null, MOCK_SERVER_BASE_URL); + }); } @Test void status() throws IOException { - // given & when & then + // given String path = SimplelocalizeCliCommandTest.class.getClassLoader().getResource("mock-api-responses/fetch-project-empty-hosting-resources.json").getPath(); String content = Files.readString(Path.of(path), StandardCharsets.UTF_8); mockServer.when(request() @@ -211,8 +226,11 @@ void status() throws IOException .withDelay(TimeUnit.MILLISECONDS, 200) ); + //when + assertDoesNotThrow(() -> { + sut.status("my-api-key", MOCK_SERVER_BASE_URL); - sut.status("my-api-key", MOCK_SERVER_BASE_URL); + }); } @@ -254,14 +272,16 @@ void purge() throws IOException //when - sut.purge("my-api-key", MOCK_SERVER_BASE_URL, true); + assertDoesNotThrow(() -> { + sut.purge("my-api-key", MOCK_SERVER_BASE_URL, true); + }); } @Test void publishLatest() throws IOException { - // given & when & then + // given String path = SimplelocalizeCliCommandTest.class.getClassLoader().getResource("mock-api-responses/fetch-project-empty-hosting-resources.json").getPath(); String content = Files.readString(Path.of(path), StandardCharsets.UTF_8); mockServer.when(request() @@ -288,14 +308,16 @@ void publishLatest() throws IOException .withDelay(TimeUnit.MILLISECONDS, 200) ); - - sut.publish("my-api-key", "_latest", MOCK_SERVER_BASE_URL); + //when + assertDoesNotThrow(() -> { + sut.publish("my-api-key", "_latest", MOCK_SERVER_BASE_URL); + }); } @Test void publishProduction() throws IOException { - // given & when & then + // given String path = SimplelocalizeCliCommandTest.class.getClassLoader().getResource("mock-api-responses/fetch-project-empty-hosting-resources.json").getPath(); String content = Files.readString(Path.of(path), StandardCharsets.UTF_8); mockServer.when(request() @@ -321,14 +343,16 @@ void publishProduction() throws IOException .withDelay(TimeUnit.MILLISECONDS, 200) ); - - sut.publish("my-api-key", "_production", MOCK_SERVER_BASE_URL); + //when + assertDoesNotThrow(() -> { + sut.publish("my-api-key", "_production", MOCK_SERVER_BASE_URL); + }); } @Test void startAutoTranslation() { - // given & when & then + // given mockServer.when(request() .withMethod("GET") .withPath("/api/v2/jobs") @@ -366,13 +390,16 @@ void startAutoTranslation() .withDelay(TimeUnit.MILLISECONDS, 200) ); - sut.startAutoTranslation("my-api-key", List.of("pl", "en"), MOCK_SERVER_BASE_URL); + //when + assertDoesNotThrow(() -> { + sut.startAutoTranslation("my-api-key", List.of("pl", "en"), MOCK_SERVER_BASE_URL); + }); } @Test void init() { - // given & when & then + // given mockServer.when(request() .withMethod("GET") .withPath("sample.yml"), @@ -386,8 +413,10 @@ void init() """) .withDelay(TimeUnit.MILLISECONDS, 200) ); - - sut.init(); + //then + assertDoesNotThrow(() -> { + sut.init(); + }); } } diff --git a/src/test/java/io/simplelocalize/cli/client/SimpleLocalizeClientTest.java b/src/test/java/io/simplelocalize/cli/client/SimpleLocalizeClientTest.java index 8a47880..36b95d8 100644 --- a/src/test/java/io/simplelocalize/cli/client/SimpleLocalizeClientTest.java +++ b/src/test/java/io/simplelocalize/cli/client/SimpleLocalizeClientTest.java @@ -1,10 +1,12 @@ package io.simplelocalize.cli.client; +import ch.qos.logback.classic.spi.ILoggingEvent; import com.google.common.net.HttpHeaders; import io.simplelocalize.cli.client.dto.DownloadRequest; import io.simplelocalize.cli.client.dto.UploadRequest; import io.simplelocalize.cli.client.dto.proxy.DownloadableFile; import io.simplelocalize.cli.exception.ApiRequestException; +import io.simplelocalize.cli.util.TestLogEventFactory; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -64,11 +66,13 @@ void shouldSendKeys() throws Exception ); SimpleLocalizeClient client = new SimpleLocalizeClient(MOCK_SERVER_BASE_URL, "237b305f6b2273e92ac857eb44d7f33b"); + List logEventList = TestLogEventFactory.createAndGetLogEventList(client.getClass()); //when client.uploadKeys(givenKeys); //then + logEventList.forEach(logEvent -> assertThat(logEvent.getFormattedMessage()).isEqualTo("1 unique keys processed")); } @Test @@ -90,17 +94,20 @@ void shouldUploadFileWithLanguageKey() throws Exception .withDelay(TimeUnit.MILLISECONDS, 200) ); - UploadRequest uploadRequest = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest uploadRequest = UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/mock-server/test.json")) .withLanguageKey(null) .withFormat("multi-language-json") .withOptions(List.of("SPLIT_BY_NAMESPACES")) .build(); + List logEventList = TestLogEventFactory.createAndGetLogEventList(client.getClass()); + //when client.uploadFile(uploadRequest); //then + logEventList.forEach(logEvent -> assertThat(logEvent.getFormattedMessage()).isEqualTo("File uploaded: test.json")); } @Test @@ -122,17 +129,21 @@ void shouldUploadFile() throws Exception .withDelay(TimeUnit.MILLISECONDS, 200) ); - UploadRequest uploadRequest = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest uploadRequest = UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/mock-server/test.json")) .withLanguageKey("en") .withFormat("multi-language-json") .withOptions(List.of()) .build(); + List logEventList = TestLogEventFactory.createAndGetLogEventList(client.getClass()); + + //when client.uploadFile(uploadRequest); //then + logEventList.forEach(logEvent -> assertThat(logEvent.getFormattedMessage()).isEqualTo("File uploaded: test.json")); } @Test @@ -154,18 +165,22 @@ void shouldLogApiErrorMessageWhenUploadFileFailed() throws Exception .withDelay(TimeUnit.MILLISECONDS, 200) ); - UploadRequest uploadRequest = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest uploadRequest = UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/mock-server/test.json")) .withLanguageKey("en") .withFormat("multi-language-json") .withOptions(List.of()) .build(); + List logEventList = TestLogEventFactory.createAndGetLogEventList(client.getClass()); + //when & then Assertions .assertThatThrownBy(() -> client.uploadFile(uploadRequest)) .isInstanceOf(ApiRequestException.class) .hasMessage("failure message"); + + logEventList.forEach(logEvent -> assertThat(logEvent.getFormattedMessage()).isEqualTo("Request failed: failure message")); } @Test @@ -187,15 +202,18 @@ void shouldGetDownloadableFiles() throws Exception .withDelay(TimeUnit.MILLISECONDS, 200) ); - DownloadRequest downloadRequest = DownloadRequest.DownloadRequestBuilder.Builder() + DownloadRequest downloadRequest = DownloadRequest.DownloadRequestBuilder.builder() .withFormat("java-properties") .withOptions(List.of("SPLIT_BY_NAMESPACES")) .build(); + List logEventList = TestLogEventFactory.createAndGetLogEventList(client.getClass()); + //when client.fetchDownloadableFiles(downloadRequest); //then + logEventList.forEach(logEvent -> assertThat(logEvent.getFormattedMessage()).isEqualTo("Downloadable files fetched: 1")); } @Test @@ -217,16 +235,18 @@ void shouldDownloadWithManyOptions() throws Exception .withDelay(TimeUnit.MILLISECONDS, 200) ); - DownloadRequest downloadRequest = DownloadRequest.DownloadRequestBuilder.Builder() + DownloadRequest downloadRequest = DownloadRequest.DownloadRequestBuilder.builder() .withFormat("java-properties") .withOptions(List.of("SPLIT_BY_NAMESPACES", "USE_NESTED_JSON")) .build(); + List logEventList = TestLogEventFactory.createAndGetLogEventList(client.getClass()); //when client.fetchDownloadableFiles(downloadRequest); //then + logEventList.forEach(logEvent -> assertThat(logEvent.getFormattedMessage()).isEqualTo("Downloadable files fetched: 1")); } diff --git a/src/test/java/io/simplelocalize/cli/client/dto/UploadRequestTest.java b/src/test/java/io/simplelocalize/cli/client/dto/UploadRequestTest.java index b94e64b..7f25b7d 100644 --- a/src/test/java/io/simplelocalize/cli/client/dto/UploadRequestTest.java +++ b/src/test/java/io/simplelocalize/cli/client/dto/UploadRequestTest.java @@ -14,14 +14,14 @@ class UploadRequestTest void shouldReturnTrueIfWhenSameObject() { //given - UploadRequest object1 = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest object1 = UploadRequest.UploadFileRequestBuilder.builder() .withFormat("format") .withLanguageKey("pl") .withOptions(List.of("OPTION")) .withPath(Path.of("./")) .build(); - UploadRequest object2 = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest object2 = UploadRequest.UploadFileRequestBuilder.builder() .withFormat("format") .withLanguageKey("pl") .withOptions(List.of("OPTION")) @@ -40,14 +40,14 @@ void shouldReturnTrueIfWhenSameObject() void shouldReturnFalseIfObjectsAreDifferent() { //given - UploadRequest object1 = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest object1 = UploadRequest.UploadFileRequestBuilder.builder() .withFormat("format") .withLanguageKey("de") .withOptions(List.of("OPTION")) .withPath(Path.of("./")) .build(); - UploadRequest object2 = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest object2 = UploadRequest.UploadFileRequestBuilder.builder() .withFormat("format") .withLanguageKey("pl") .withOptions(List.of("OPTION")) @@ -66,14 +66,14 @@ void shouldReturnFalseIfObjectsAreDifferent() void testHashCode() { //given - UploadRequest object1 = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest object1 = UploadRequest.UploadFileRequestBuilder.builder() .withFormat("format") .withLanguageKey("pl") .withOptions(List.of("OPTION")) .withPath(Path.of("./")) .build(); - UploadRequest object2 = UploadRequest.UploadFileRequestBuilder.Builder() + UploadRequest object2 = UploadRequest.UploadFileRequestBuilder.builder() .withFormat("format") .withLanguageKey("pl") .withOptions(List.of("OPTION")) diff --git a/src/test/java/io/simplelocalize/cli/command/DownloadCommandTest.java b/src/test/java/io/simplelocalize/cli/command/DownloadCommandTest.java index a6f0a14..b7bf536 100644 --- a/src/test/java/io/simplelocalize/cli/command/DownloadCommandTest.java +++ b/src/test/java/io/simplelocalize/cli/command/DownloadCommandTest.java @@ -11,7 +11,7 @@ import java.util.List; -import static io.simplelocalize.cli.client.dto.DownloadRequest.DownloadRequestBuilder.Builder; +import static io.simplelocalize.cli.client.dto.DownloadRequest.DownloadRequestBuilder.builder; @ExtendWith(MockitoExtension.class) public class DownloadCommandTest @@ -32,14 +32,14 @@ public void shouldDownloadMultipleFiles() throws Exception configuration.setDownloadFormat("android"); //when - Mockito.when(client.fetchDownloadableFiles(Builder() + Mockito.when(client.fetchDownloadableFiles(builder() .withFormat("android") .withLanguageKey("en") .withOptions(List.of("SPLIT_BY_NAMESPACES")) .build())) .thenReturn(List.of( - DownloadableFile.DownloadableFileBuilder.Builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file1.xml").build(), - DownloadableFile.DownloadableFileBuilder.Builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file2.xml").build() + DownloadableFile.DownloadableFileBuilder.builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file1.xml").build(), + DownloadableFile.DownloadableFileBuilder.builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file2.xml").build() )); DownloadCommand downloadCommand = new DownloadCommand(client, configuration); @@ -48,11 +48,11 @@ public void shouldDownloadMultipleFiles() throws Exception //then Mockito.verify(client, Mockito.times(1)) .downloadFile( - DownloadableFile.DownloadableFileBuilder.Builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file1.xml").build(), + DownloadableFile.DownloadableFileBuilder.builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file1.xml").build(), "./my-project-path"); Mockito.verify(client, Mockito.times(1)) .downloadFile( - DownloadableFile.DownloadableFileBuilder.Builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file2.xml").build(), + DownloadableFile.DownloadableFileBuilder.builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file2.xml").build(), "./my-project-path"); } } diff --git a/src/test/java/io/simplelocalize/cli/command/UploadCommandTest.java b/src/test/java/io/simplelocalize/cli/command/UploadCommandTest.java index e6b9c73..4c1a8ef 100644 --- a/src/test/java/io/simplelocalize/cli/command/UploadCommandTest.java +++ b/src/test/java/io/simplelocalize/cli/command/UploadCommandTest.java @@ -54,7 +54,7 @@ public void shouldUploadTwelveFiles() throws Exception //then Mockito.verify(client, times(12)).uploadFile( - Mockito.refEq(UploadRequest.UploadFileRequestBuilder.Builder() + Mockito.refEq(UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/download-test/values-{lang}/strings.xml")) .withFormat("android") .withOptions(Collections.emptyList()) @@ -80,7 +80,7 @@ public void shouldUploadOneFileWithLangTemplate() throws Exception //then Mockito.verify(client, times(1)).uploadFile( - Mockito.refEq(UploadRequest.UploadFileRequestBuilder.Builder() + Mockito.refEq(UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/download-test/values-{lang}/strings.xml")) .withFormat("android") .withLanguageKey("en") @@ -106,7 +106,7 @@ public void shouldUploadOneFileWithOnlyTranslationKeys() throws Exception //then Mockito.verify(client, times(1)).uploadFile( - Mockito.refEq(UploadRequest.UploadFileRequestBuilder.Builder() + Mockito.refEq(UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/download-test/values-en/strings.xml")) .withFormat("android") .withLanguageKey("") @@ -149,7 +149,7 @@ public void shouldUploadOneFile() throws Exception //then Mockito.verify(client, times(1)).uploadFile( - Mockito.refEq(UploadRequest.UploadFileRequestBuilder.Builder() + Mockito.refEq(UploadRequest.UploadFileRequestBuilder.builder() .withPath(Path.of("./junit/download-test/values-{lang}/strings.xml")) .withFormat("android") .withLanguageKey("en") diff --git a/src/test/java/io/simplelocalize/cli/util/FileListReaderTest.java b/src/test/java/io/simplelocalize/cli/util/FileListReaderTest.java index e7e8bbc..5071846 100644 --- a/src/test/java/io/simplelocalize/cli/util/FileListReaderTest.java +++ b/src/test/java/io/simplelocalize/cli/util/FileListReaderTest.java @@ -9,7 +9,7 @@ import java.nio.file.Paths; import java.util.List; -import static io.simplelocalize.cli.client.dto.FileToUpload.FileToUploadBuilder.Builder; +import static io.simplelocalize.cli.client.dto.FileToUpload.FileToUploadBuilder.builder; class FileListReaderTest { @@ -29,22 +29,22 @@ void shouldFindJsonFilesWithInLocaleDirectoryWhenNamespaceFirst() throws IOExcep //then Assertions.assertThat(result) .containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/locale-directory-namespace-first/common/en.json")) .withLanguage("en") .withNamespace("common") .build(), - Builder() + builder() .withPath(Paths.get("./junit/locale-directory-namespace-first/home/en.json")) .withLanguage("en") .withNamespace("home") .build(), - Builder() + builder() .withPath(Paths.get("./junit/locale-directory-namespace-first/common/pl.json")) .withLanguage("pl") .withNamespace("common") .build(), - Builder() + builder() .withPath(Paths.get("./junit/locale-directory-namespace-first/home/pl.json")) .withLanguage("pl") .withNamespace("home") @@ -64,22 +64,22 @@ void shouldFindJsonFilesWithInLocaleDirectory() throws IOException //then Assertions.assertThat(result) .containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/locale-directory/en/common.json")) .withLanguage("en") .withNamespace("common") .build(), - Builder() + builder() .withPath(Paths.get("./junit/locale-directory/en/home.json")) .withLanguage("en") .withNamespace("home") .build(), - Builder() + builder() .withPath(Paths.get("./junit/locale-directory/pl/common.json")) .withLanguage("pl") .withNamespace("common") .build(), - Builder() + builder() .withPath(Paths.get("./junit/locale-directory/pl/home.json")) .withLanguage("pl") .withNamespace("home") @@ -98,12 +98,12 @@ void shouldFindFilesWithLangInDirectoryName() throws IOException //then Assertions.assertThat(result).containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/lang-in-directory/en/strings.xml")) .withLanguage("en") .withNamespace(null) .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-in-directory/es/strings.xml")) .withLanguage("es") .withNamespace(null) @@ -122,12 +122,12 @@ void shouldFindFilesWithLangInDirectoryNameWithPrefix() throws IOException //then Assertions.assertThat(result).containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/lang-in-directory-with-prefix/values-en/strings.xml")) .withLanguage("en") .withNamespace(null) .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-in-directory-with-prefix/values-es/strings.xml")) .withLanguage("es") .withNamespace(null) @@ -146,12 +146,12 @@ void shouldFindFilesWithLangInFilename() throws IOException //then Assertions.assertThat(result).containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/lang-in-filename/en.json")) .withLanguage("en") .withNamespace(null) .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-in-filename/es.json")) .withLanguage("es") .withNamespace(null) @@ -170,17 +170,17 @@ void shouldFindFilesWithLangInFilenameAndProperties() throws IOException //then Assertions.assertThat(result).containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/lang-in-filename-suffix/messages_de.properties")) .withLanguage("de") .withNamespace(null) .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-in-filename-suffix/messages_pl-PL.properties")) .withLanguage("pl-PL") .withNamespace(null) .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-in-filename-suffix/messages_pl.properties")) .withLanguage("pl") .withNamespace(null) @@ -199,7 +199,7 @@ void shouldFindOneWithoutTemplateKeys() throws IOException //then Assertions.assertThat(result).containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/lang-in-filename-suffix/messages_pl.properties")) .withLanguage(null) .withNamespace(null) @@ -221,32 +221,32 @@ void shouldFindTranslationsWhenExtremeEdgeCases() throws IOException Assertions .assertThat(result) .containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/extreme-edge-cases/meaningless-directory/email_messages_de-DE.properties")) .withLanguage("de-DE") .withNamespace("email_messages") .build(), - Builder() + builder() .withPath(Paths.get("./junit/extreme-edge-cases/meaningless-directory/email_messages_en%US.properties")) .withLanguage("en%US") .withNamespace("email_messages") .build(), - Builder() + builder() .withPath(Paths.get("./junit/extreme-edge-cases/meaningless-directory/email_messages_es-ES.properties")) .withLanguage("es-ES") .withNamespace("email_messages") .build(), - Builder() + builder() .withPath(Paths.get("./junit/extreme-edge-cases/meaningless-directory/home_en-GB.properties")) .withLanguage("en-GB") .withNamespace("home") .build(), - Builder() + builder() .withPath(Paths.get("./junit/extreme-edge-cases/meaningless-directory/home-en_GB.properties")) .withLanguage("GB") .withNamespace("home-en") .build(), - Builder() + builder() .withPath(Paths.get("./junit/extreme-edge-cases/meaningless-directory/home_pl-PL.properties")) .withLanguage("pl-PL") .withNamespace("home") @@ -266,22 +266,22 @@ void langAsDirectoriesNsAsFilename() throws IOException //then Assertions.assertThat(result).hasSize(4) .containsExactlyInAnyOrder( - Builder() + builder() .withPath(Paths.get("./junit/lang-as-directories-ns-as-filename/meaningless-directory/en/common.json")) .withLanguage("en") .withNamespace("common") .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-as-directories-ns-as-filename/meaningless-directory/en/home.json")) .withLanguage("en") .withNamespace("home") .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-as-directories-ns-as-filename/meaningless-directory/es/home.json")) .withLanguage("es") .withNamespace("home") .build(), - Builder() + builder() .withPath(Paths.get("./junit/lang-as-directories-ns-as-filename/meaningless-directory/pl/common.json")) .withLanguage("pl") .withNamespace("common") diff --git a/src/test/java/io/simplelocalize/cli/util/TestLogEventFactory.java b/src/test/java/io/simplelocalize/cli/util/TestLogEventFactory.java index 6638e39..4b8db62 100644 --- a/src/test/java/io/simplelocalize/cli/util/TestLogEventFactory.java +++ b/src/test/java/io/simplelocalize/cli/util/TestLogEventFactory.java @@ -17,4 +17,23 @@ public static List createAndGetLogEventList(Class clazz) logger.addAppender(listAppender); return listAppender.list; } + + public static void verifyLogEvents(List logEventList, List strings) + { + if (logEventList.isEmpty()) + { + throw new AssertionError("Log event list is empty"); + } + + for (int i = 0; i < logEventList.size(); i++) + { + ILoggingEvent loggingEvent = logEventList.get(i); + String expected = strings.get(i); + String actual = loggingEvent.getFormattedMessage(); + if (!actual.equals(expected)) + { + throw new AssertionError("Expected: " + expected + " but was: " + actual); + } + } + } }