2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.knx.internal.i18n;
15 import static java.util.Map.entry;
17 import java.text.MessageFormat;
18 import java.util.Locale;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.core.i18n.TranslationProvider;
24 import org.osgi.framework.Bundle;
27 * Translation provider for unit tests.
29 * @author Jacob Laursen - Initial contribution
30 * @author Holger Friedrich - Imported from hdpowerview, adapted
33 public class MockedTranslationProvider implements TranslationProvider {
35 private static final Map<String, String> TEXTS = Map.ofEntries(entry("binding.knx.name", "KNX Binding"),
36 entry("error.knx-unknown-ip-connection-type", "Unknown IP connection type: {0}."),
37 entry("exception.KNXException", "Translated KNX Exception"));
39 public MockedTranslationProvider() {
43 public String getText(@Nullable Bundle bundle, @Nullable String key, @Nullable String defaultText,
44 @Nullable Locale locale) {
49 public String getText(@Nullable Bundle bundle, @Nullable String key, @Nullable String defaultText,
50 @Nullable Locale locale, @Nullable Object @Nullable... arguments) {
51 String text = TEXTS.get(key);
52 return MessageFormat.format(text != null ? text : key, arguments);