mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Implemented the result enriching
With this task, I opened the I18N and enriched the Function annotations
This commit is contained in:
1 parent
0350a54dec
commit
8edc00920a
38 files changed
+372
-266
No files matched your search
@@ -3,5 +3,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,4 +1,5 @@
|
||||
source.. = src/
|
||||
source.. = src/,\
|
||||
resources/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
SimpleTestMessage=Deutsch
|
||||
TestMessageWithParameters=Deutsch {0} - {1}
|
||||
dimension = dimension-deutsch
|
||||
value = sideEffectFreeValue-deutsch
|
||||
regattaName = Regatta Name
|
||||
crossSum = Quersumme
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
SimpleTestMessage=English
|
||||
TestMessageWithParameters=English {0} - {1}
|
||||
dimension = dimension-english
|
||||
value = sideEffectFreeValue-english
|
||||
regattaName = Regatta Name
|
||||
crossSum = Cross Sum
|
||||
+3
-5
@@ -36,11 +36,11 @@ import com.sap.sse.datamining.test.components.util.BlockingProcessor;
|
||||
import com.sap.sse.datamining.test.components.util.Number;
|
||||
import com.sap.sse.datamining.test.util.ConcurrencyTestsUtil;
|
||||
import com.sap.sse.datamining.test.util.FunctionTestsUtil;
|
||||
import com.sap.sse.datamining.test.util.StringMessagesForTests;
|
||||
import com.sap.sse.datamining.test.util.TestsUtil;
|
||||
|
||||
public class TestProcessorQuery {
|
||||
|
||||
private final static DataMiningStringMessages stringMessages = new StringMessagesForTests();
|
||||
private final static DataMiningStringMessages stringMessages = TestsUtil.getTestStringMessagesWithProductiveMessages();
|
||||
|
||||
private boolean receivedElementOrFinished;
|
||||
private boolean receivedAbort;
|
||||
@@ -129,14 +129,12 @@ public class TestProcessorQuery {
|
||||
results.put(new GenericGroupKey<Integer>(3), 3.0);
|
||||
results.put(new GenericGroupKey<Integer>(4), 10.0);
|
||||
|
||||
QueryResultImpl<Double> result = new QueryResultImpl<>(results, new AdditionalResultDataImpl(dataSource.size(), 2, "Cross sum (Sum)", Unit.None, 0, 0));
|
||||
QueryResultImpl<Double> result = new QueryResultImpl<>(results, new AdditionalResultDataImpl(dataSource.size(), 2, "Cross Sum (Sum)", Unit.None, 0, 0));
|
||||
return result;
|
||||
}
|
||||
|
||||
private void verifyResult(QueryResult<Double> result, QueryResult<Double> expectedResult) {
|
||||
assertThat("Result values aren't correct.", result.getResults(), is(expectedResult.getResults()));
|
||||
// assertThat("Retrieved data amount isn't correct.", result.getRetrievedDataAmount(), is(expectedResult.getRetrievedDataAmount()));
|
||||
assertThat("Filtered data amount isn't correct.", result.getFilteredDataAmount(), is(expectedResult.getFilteredDataAmount()));
|
||||
assertThat("Result signifier isn't correct.", result.getResultSignifier(), is(expectedResult.getResultSignifier()));
|
||||
assertThat("Unit isn't correct.", result.getUnit(), is(expectedResult.getUnit()));
|
||||
assertThat("Value decimals aren't correct.", result.getValueDecimals(), is(expectedResult.getValueDecimals()));
|
||||
|
||||
+3
-2
@@ -13,16 +13,17 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sse.datamining.factories.FunctionFactory;
|
||||
import com.sap.sse.datamining.functions.Function;
|
||||
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
|
||||
import com.sap.sse.datamining.shared.dto.FunctionDTO;
|
||||
import com.sap.sse.datamining.shared.impl.dto.FunctionDTOImpl;
|
||||
import com.sap.sse.datamining.test.function.test_classes.ExternalLibraryClass;
|
||||
import com.sap.sse.datamining.test.function.test_classes.SimpleClassWithMarkedMethods;
|
||||
import com.sap.sse.datamining.test.util.FunctionTestsUtil;
|
||||
import com.sap.sse.datamining.test.util.StringMessagesForTests;
|
||||
import com.sap.sse.datamining.test.util.TestsUtil;
|
||||
|
||||
public class TestFunctionDTOConstruction {
|
||||
|
||||
private static final StringMessagesForTests stringMessages = new StringMessagesForTests();
|
||||
private static final DataMiningStringMessages stringMessages = TestsUtil.getTestStringMessages();
|
||||
|
||||
private Method dimensionMethod;
|
||||
private Method sideEffectFreeValueMethod;
|
||||
|
||||
+2
-2
@@ -30,11 +30,11 @@ import com.sap.sse.datamining.test.function.test_classes.ExtendingInterface;
|
||||
import com.sap.sse.datamining.test.function.test_classes.ExternalLibraryClass;
|
||||
import com.sap.sse.datamining.test.function.test_classes.SimpleClassWithMarkedMethods;
|
||||
import com.sap.sse.datamining.test.util.FunctionTestsUtil;
|
||||
import com.sap.sse.datamining.test.util.StringMessagesForTests;
|
||||
import com.sap.sse.datamining.test.util.TestsUtil;
|
||||
|
||||
public class TestFunctionProvider {
|
||||
|
||||
private static final DataMiningStringMessages stringMessages = new StringMessagesForTests();
|
||||
private static final DataMiningStringMessages stringMessages = TestsUtil.getTestStringMessagesWithProductiveMessages();
|
||||
|
||||
private FunctionRegistry functionRegistry;
|
||||
|
||||
|
||||
+3
-2
@@ -11,11 +11,12 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sse.datamining.factories.FunctionFactory;
|
||||
import com.sap.sse.datamining.functions.Function;
|
||||
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
|
||||
import com.sap.sse.datamining.impl.functions.MethodWrappingFunction;
|
||||
import com.sap.sse.datamining.test.function.test_classes.ExternalLibraryClass;
|
||||
import com.sap.sse.datamining.test.function.test_classes.SimpleClassWithMarkedMethods;
|
||||
import com.sap.sse.datamining.test.util.FunctionTestsUtil;
|
||||
import com.sap.sse.datamining.test.util.StringMessagesForTests;
|
||||
import com.sap.sse.datamining.test.util.TestsUtil;
|
||||
|
||||
public class TestMethodWrappingFunction {
|
||||
|
||||
@@ -50,7 +51,7 @@ public class TestMethodWrappingFunction {
|
||||
|
||||
@Test
|
||||
public void testGetLocalizedName() {
|
||||
StringMessagesForTests stringMessages = new StringMessagesForTests();
|
||||
DataMiningStringMessages stringMessages = TestsUtil.getTestStringMessages();
|
||||
|
||||
Function<?> dimension = FunctionFactory.createMethodWrappingFunction(dimensionMethod);
|
||||
String expectedEnglishName = "dimension-english";
|
||||
|
||||
+4
-11
@@ -8,36 +8,29 @@ import java.util.Locale;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sse.datamining.test.util.OpenResourceBundleManager;
|
||||
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
|
||||
import com.sap.sse.datamining.test.util.TestsUtil;
|
||||
|
||||
public class TestI18N {
|
||||
|
||||
private static final String SIMPLE_TEST_MESSAGE_KEY = "SimpleTestMessage";
|
||||
private static final String TEST_MESSAGE_WITH_PARAMETERS = "TestMessageWithParameters";
|
||||
|
||||
private OpenResourceBundleManager bundleManager;
|
||||
private DataMiningStringMessages bundleManager;
|
||||
|
||||
@Before
|
||||
public void initializeBundleManager() {
|
||||
bundleManager = new OpenResourceBundleManager(Locale.ENGLISH);
|
||||
bundleManager = TestsUtil.getTestStringMessages();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGettingASimpleMessage() {
|
||||
assertThat(bundleManager.get("default", SIMPLE_TEST_MESSAGE_KEY), is("English"));
|
||||
assertThat(bundleManager.get("en", SIMPLE_TEST_MESSAGE_KEY), is("English"));
|
||||
assertThat(bundleManager.get("de", SIMPLE_TEST_MESSAGE_KEY), is("Deutsch"));
|
||||
|
||||
assertThat(bundleManager.get(Locale.ENGLISH, SIMPLE_TEST_MESSAGE_KEY), is("English"));
|
||||
assertThat(bundleManager.get(Locale.GERMAN, SIMPLE_TEST_MESSAGE_KEY), is("Deutsch"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGettingAMessageWithParameters() {
|
||||
assertThat(bundleManager.get("default", TEST_MESSAGE_WITH_PARAMETERS, "Param0", "Param1"), is("English Param0 - Param1"));
|
||||
assertThat(bundleManager.get("en", TEST_MESSAGE_WITH_PARAMETERS, "Param0", "Param1"), is("English Param0 - Param1"));
|
||||
assertThat(bundleManager.get("de", TEST_MESSAGE_WITH_PARAMETERS, "Param0", "Param1"), is("Deutsch Param0 - Param1"));
|
||||
|
||||
assertThat(bundleManager.get(Locale.ENGLISH, TEST_MESSAGE_WITH_PARAMETERS, "Param0", "Param1"), is("English Param0 - Param1"));
|
||||
assertThat(bundleManager.get(Locale.GERMAN, TEST_MESSAGE_WITH_PARAMETERS, "Param0", "Param1"), is("Deutsch Param0 - Param1"));
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,12 +19,12 @@ public class Number {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Dimension("length")
|
||||
@Dimension(messageKey="length")
|
||||
public int getLength() {
|
||||
return String.valueOf(value).length();
|
||||
}
|
||||
|
||||
@Dimension("crossSum")
|
||||
@Dimension(messageKey="crossSum")
|
||||
public int getCrossSum() {
|
||||
int crossSum = 0;
|
||||
int value = this.value;
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package com.sap.sse.datamining.test.function.test_classes;
|
||||
|
||||
import com.sap.sse.datamining.annotations.SideEffectFreeValue;
|
||||
import com.sap.sse.datamining.shared.Unit;
|
||||
|
||||
public interface DataTypeInterface {
|
||||
|
||||
@SideEffectFreeValue("speedInKnots")
|
||||
@SideEffectFreeValue(messageKey="speedInKnots", resultUnit=Unit.Knots, resultDecimals=2)
|
||||
public int getSpeedInKnots();
|
||||
|
||||
}
|
||||
+3
-3
@@ -9,13 +9,13 @@ import com.sap.sse.datamining.annotations.Dimension;
|
||||
|
||||
public interface DataTypeWithContext extends DataTypeInterface {
|
||||
|
||||
@Dimension("regattaName")
|
||||
@Dimension(messageKey="regattaName")
|
||||
public String getRegattaName();
|
||||
|
||||
@Dimension("raceName")
|
||||
@Dimension(messageKey="raceName")
|
||||
public String getRaceName();
|
||||
|
||||
@Dimension("legNumber")
|
||||
@Dimension(messageKey="legNumber")
|
||||
public int getLegNumber();
|
||||
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import com.sap.sse.datamining.annotations.Dimension;
|
||||
|
||||
public class DataTypeWithContextProcessor {
|
||||
|
||||
@Dimension("regattaAndRaceName")
|
||||
@Dimension(messageKey="regattaAndRaceName")
|
||||
public String getRegattaAndRaceName(DataTypeWithContext dataEntry) {
|
||||
return dataEntry.getRegattaName() + " - " + dataEntry.getRaceName();
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import com.sap.sse.datamining.annotations.SideEffectFreeValue;
|
||||
|
||||
public interface ExtendingInterface {
|
||||
|
||||
@SideEffectFreeValue("raceNameLength")
|
||||
@SideEffectFreeValue(messageKey="raceNameLength")
|
||||
public int getRaceNameLength();
|
||||
|
||||
}
|
||||
+3
-3
@@ -10,18 +10,18 @@ import com.sap.sse.datamining.annotations.SideEffectFreeValue;
|
||||
|
||||
public class SimpleClassWithMarkedMethods {
|
||||
|
||||
@Dimension("dimension")
|
||||
@Dimension(messageKey="dimension")
|
||||
public String dimension() {
|
||||
return "Method marked as dimension";
|
||||
}
|
||||
|
||||
//Methods without a return value can't be dimensions
|
||||
@Dimension("illegalDimension")
|
||||
@Dimension(messageKey="illegalDimension")
|
||||
public void illegalDimension() {
|
||||
|
||||
}
|
||||
|
||||
@SideEffectFreeValue("value")
|
||||
@SideEffectFreeValue(messageKey="value")
|
||||
public int sideEffectFreeValue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.sap.sse.datamining.components.Processor;
|
||||
|
||||
public class ConcurrencyTestsUtil {
|
||||
public class ConcurrencyTestsUtil extends TestsUtil {
|
||||
|
||||
private static final int THREAD_POOL_SIZE = Math.max(Runtime.getRuntime().availableProcessors(), 3);
|
||||
private static ThreadPoolExecutor executor = createExecutor();
|
||||
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package com.sap.sse.datamining.test.util;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.sap.sse.datamining.impl.i18n.DataMiningResourceBundleManager;
|
||||
|
||||
public class OpenResourceBundleManager extends DataMiningResourceBundleManager {
|
||||
|
||||
public OpenResourceBundleManager(Locale defaultLocale) {
|
||||
super(defaultLocale);
|
||||
}
|
||||
|
||||
public String get(Locale locale, String message, String... parameters) {
|
||||
return super.get(locale, message, parameters);
|
||||
}
|
||||
|
||||
public String get(Locale locale, String message) {
|
||||
return super.get(locale, message, new String[0]);
|
||||
}
|
||||
|
||||
public String get(String localeName, String message, String... parameters) {
|
||||
return this.get(getLocaleFrom(localeName), message, parameters);
|
||||
}
|
||||
|
||||
public String get(String localeName, String message) {
|
||||
return this.get(getLocaleFrom(localeName), message);
|
||||
}
|
||||
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package com.sap.sse.datamining.test.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
|
||||
import com.sap.sse.datamining.shared.Message;
|
||||
|
||||
public class StringMessagesForTests implements DataMiningStringMessages {
|
||||
|
||||
private final Map<Locale, Map<String, String>> messages;
|
||||
|
||||
public StringMessagesForTests() {
|
||||
messages = new HashMap<>();
|
||||
initializeEnglishMessages();
|
||||
initializeGermanMessages();
|
||||
}
|
||||
|
||||
private void initializeEnglishMessages() {
|
||||
Map<String, String> englishMessages = new HashMap<>();
|
||||
messages.put(Locale.ENGLISH, englishMessages);
|
||||
|
||||
englishMessages.put("dimension", "dimension-english");
|
||||
englishMessages.put("value", "sideEffectFreeValue-english");
|
||||
}
|
||||
|
||||
private void initializeGermanMessages() {
|
||||
Map<String, String> germanMessages = new HashMap<>();
|
||||
messages.put(Locale.GERMAN, germanMessages);
|
||||
|
||||
germanMessages.put("dimension", "dimension-deutsch");
|
||||
germanMessages.put("value", "sideEffectFreeValue-deutsch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocaleFrom(String localeName) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale locale, Message message) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale locale, Message message, String... parameters) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale locale, Message message, Message... parameters) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale locale, String messageKey) {
|
||||
return messages.get(locale).get(messageKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale locale, String messageKey, String... parameters) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.sap.sse.datamining.test.util;
|
||||
|
||||
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
|
||||
|
||||
public class TestsUtil {
|
||||
|
||||
private static final String TEST_STRING_MESSAGES_BASE_NAME = "stringmessages/Test_StringMessages";
|
||||
private static final DataMiningStringMessages TEST_STRING_MESSAGES = DataMiningStringMessages.Util.getInstanceFor(TEST_STRING_MESSAGES_BASE_NAME);
|
||||
private static final DataMiningStringMessages EXTENDED_STRING_MESSAGES = DataMiningStringMessages.Util.getCompoundStringMessages(
|
||||
DataMiningStringMessages.Util.getDefaultStringMessagesBaseName(),
|
||||
TEST_STRING_MESSAGES_BASE_NAME);
|
||||
|
||||
public static DataMiningStringMessages getTestStringMessages() {
|
||||
return TEST_STRING_MESSAGES;
|
||||
}
|
||||
|
||||
public static DataMiningStringMessages getTestStringMessagesWithProductiveMessages() {
|
||||
return EXTENDED_STRING_MESSAGES;
|
||||
}
|
||||
|
||||
protected TestsUtil() { }
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user