From 3ea7746f4d86e7f56b2508835a8e8e02dda4d778 Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Mon, 29 Feb 2016 15:56:33 +0100 Subject: [PATCH 001/178] deep link server change --- .../AndroidManifest.xml | 16 ++++++ .../res/values-de/strings.xml | 1 + .../res/values/strings.xml | 1 + .../app/ui/activities/LoginActivity.java | 13 +++++ .../app/ui/fragments/LoginOnboarding.java | 30 ++--------- .../preference/GeneralPreferenceFragment.java | 27 +--------- .../racecommittee/app/utils/QRHelper.java | 54 +++++++++++++++++++ 7 files changed, 90 insertions(+), 52 deletions(-) create mode 100644 mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java diff --git a/mobile/com.sap.sailing.racecommittee.app/AndroidManifest.xml b/mobile/com.sap.sailing.racecommittee.app/AndroidManifest.xml index ff63e9cb333..2e54399fa00 100644 --- a/mobile/com.sap.sailing.racecommittee.app/AndroidManifest.xml +++ b/mobile/com.sap.sailing.racecommittee.app/AndroidManifest.xml @@ -51,6 +51,22 @@ + + + + + + + + + + diff --git a/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml b/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml index a5052b5b831..5713d12e5a1 100644 --- a/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml +++ b/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml @@ -465,5 +465,6 @@ Select Race Getting Started http://www.sapsailing.com/gwt/Home.html?locale=de#SolutionsPlace:navigationTab=RaceCommitteeApp + Server erfolgreich geƤndert auf %1$s. \ No newline at end of file diff --git a/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml b/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml index f17e4036d2f..b26e93ce0a0 100644 --- a/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml +++ b/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml @@ -492,5 +492,6 @@ Select Race Getting Started http://www.sapsailing.com/gwt/Home.html?locale=en#SolutionsPlace:navigationTab=RaceCommitteeApp + Server successful changed to %1$s. \ No newline at end of file diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/activities/LoginActivity.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/activities/LoginActivity.java index 346957719f2..2deca9ce6fb 100755 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/activities/LoginActivity.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/activities/LoginActivity.java @@ -21,6 +21,7 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.v4.content.LocalBroadcastManager; +import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -63,6 +64,7 @@ import com.sap.sailing.racecommittee.app.ui.fragments.lists.selection.CourseArea import com.sap.sailing.racecommittee.app.ui.fragments.lists.selection.EventSelectedListenerHost; import com.sap.sailing.racecommittee.app.ui.fragments.lists.selection.ItemSelectedListener; import com.sap.sailing.racecommittee.app.ui.fragments.lists.selection.PositionSelectedListenerHost; +import com.sap.sailing.racecommittee.app.utils.QRHelper; import com.sap.sailing.racecommittee.app.utils.StringHelper; import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; @@ -289,6 +291,17 @@ public class LoginActivity extends BaseActivity } } + String action = getIntent().getAction(); + if (Intent.ACTION_VIEW.equals(action)) { + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_AlertDialog); + builder.setTitle(R.string.app_name); + if (QRHelper.with(this).saveData(getIntent().getData().toString())) { + builder.setMessage(getString(R.string.server_deeplink_message, preferences.getServerBaseURL())); + } + builder.setPositiveButton(android.R.string.ok, null); + builder.show(); + } + // This is required to reactivate the loader manager after configuration change (screen rotation) getLoaderManager(); diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java index afacb98e747..14b8aed4f28 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java @@ -27,6 +27,7 @@ import com.sap.sailing.domain.common.impl.DeviceConfigurationQRCodeUtils; import com.sap.sailing.racecommittee.app.AppConstants; import com.sap.sailing.racecommittee.app.AppPreferences; import com.sap.sailing.racecommittee.app.R; +import com.sap.sailing.racecommittee.app.utils.QRHelper; import com.sap.sailing.racecommittee.app.utils.UrlHelper; import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; import com.sap.sse.common.Util; @@ -88,7 +89,7 @@ public class LoginOnboarding extends Fragment { builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (saveData(url.getText().toString() + "#" + DeviceConfigurationQRCodeUtils.fragmentKey + "=" + device_id.getText().toString())) { + if (QRHelper.with(getActivity()).saveData(url.getText().toString() + "#" + DeviceConfigurationQRCodeUtils.fragmentKey + "=" + device_id.getText().toString())) { LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent(AppConstants.INTENT_ACTION_RESET)); } } @@ -116,36 +117,11 @@ public class LoginOnboarding extends Fragment { break; case Activity.RESULT_OK: - saveData(data.getStringExtra("SCAN_RESULT")); + QRHelper.with(getActivity()).saveData(data.getStringExtra("SCAN_RESULT")); break; default: Toast.makeText(getActivity(), getString(R.string.error_scanning_qr, resultCode), Toast.LENGTH_LONG).show(); } } - - private boolean saveData(String content) { - try { - Util.Pair connectionConfiguration = DeviceConfigurationQRCodeUtils.splitQRContent(content); - - String identifier = connectionConfiguration.getA(); - URL apkUrl = UrlHelper.tryConvertToURL(connectionConfiguration.getB()); - - if (apkUrl != null) { - String serverUrl = UrlHelper.getServerUrl(apkUrl); - - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - preferences.edit().putString(getString(R.string.preference_identifier_key), identifier).commit(); - preferences.edit().putString(getString(R.string.preference_server_url_key), serverUrl).commit(); - - new AutoUpdater(getActivity()).checkForUpdate(false); - return true; - } else { - Toast.makeText(getActivity(), getString(R.string.error_scanning_qr_malformed), Toast.LENGTH_LONG).show(); - } - } catch (IllegalArgumentException e) { - Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); - } - return false; - } } diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java index 687ba0d1e6d..e1335d2e904 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java @@ -24,6 +24,7 @@ import com.sap.sailing.domain.common.impl.DeviceConfigurationQRCodeUtils; import com.sap.sailing.racecommittee.app.AppPreferences; import com.sap.sailing.racecommittee.app.BuildConfig; import com.sap.sailing.racecommittee.app.R; +import com.sap.sailing.racecommittee.app.utils.QRHelper; import com.sap.sailing.racecommittee.app.utils.UrlHelper; import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; import com.sap.sse.common.Util; @@ -187,31 +188,7 @@ public class GeneralPreferenceFragment extends BasePreferenceFragment { } if (resultCode == Activity.RESULT_OK) { - String content = data.getStringExtra("SCAN_RESULT"); - try { - Util.Pair connectionConfiguration = DeviceConfigurationQRCodeUtils.splitQRContent(content); - - String identifier = connectionConfiguration.getA(); - URL apkUrl = UrlHelper.tryConvertToURL(connectionConfiguration.getB()); - - if (apkUrl != null) { - String serverUrl = UrlHelper.getServerUrl(apkUrl); - - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - preferences.edit().putString(getString(R.string.preference_identifier_key), identifier).commit(); - preferences.edit().putString(getString(R.string.preference_server_url_key), serverUrl).commit(); - - identifierPreference.getOnPreferenceChangeListener().onPreferenceChange(identifierPreference, identifier); - serverUrlPreference.setText(serverUrl); - serverUrlPreference.getOnPreferenceChangeListener().onPreferenceChange(serverUrlPreference, serverUrl); - - new AutoUpdater(getActivity()).checkForUpdate(false); - } else { - Toast.makeText(getActivity(), getString(R.string.error_scanning_qr_malformed), Toast.LENGTH_LONG).show(); - } - } catch (IllegalArgumentException e) { - Toast.makeText(getActivity(), getString(R.string.error_scanning_qr, e.getMessage()), Toast.LENGTH_LONG).show(); - } + QRHelper.with(getActivity()).saveData(data.getStringExtra("SCAN_RESULT")); } else { Toast.makeText(getActivity(), getString(R.string.error_scanning_qr, resultCode), Toast.LENGTH_LONG).show(); } diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java new file mode 100644 index 00000000000..f4e755b6722 --- /dev/null +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java @@ -0,0 +1,54 @@ +package com.sap.sailing.racecommittee.app.utils; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.widget.Toast; + +import com.sap.sailing.domain.common.impl.DeviceConfigurationQRCodeUtils; +import com.sap.sailing.racecommittee.app.R; +import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; +import com.sap.sse.common.Util; + +import java.net.URL; + +public class QRHelper { + + private Context mContext; + + private QRHelper(Context context) { + mContext = context; + } + + public static QRHelper with(Context context) { + return new QRHelper(context); + } + + public boolean saveData(String content) { + try { + Util.Pair connectionConfiguration = DeviceConfigurationQRCodeUtils.splitQRContent(content); + + String identifier = connectionConfiguration.getA(); + URL apkUrl = UrlHelper.tryConvertToURL(connectionConfiguration.getB()); + + if (apkUrl != null) { + String serverUrl = UrlHelper.getServerUrl(apkUrl); + + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences.Editor editor = preferences.edit(); + editor.putString(mContext.getString(R.string.preference_identifier_key), identifier); + editor.putString(mContext.getString(R.string.preference_server_url_key), serverUrl); + editor.commit(); + + new AutoUpdater(mContext).checkForUpdate(false); + return true; + } else { + Toast.makeText(mContext, mContext.getString(R.string.error_scanning_qr_malformed), Toast.LENGTH_LONG).show(); + } + } catch (IllegalArgumentException e) { + Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_LONG).show(); + } + return false; + } +} From 0910f032cc3b3ad6ef4882518aa31caf9992884e Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Mon, 29 Feb 2016 16:54:11 +0100 Subject: [PATCH 002/178] consolidated imports to avoid warnings Change-Id: I2abdf8efd22c07da16a5a1b8c6817ae2722cad1e --- .../racecommittee/app/ui/fragments/LoginOnboarding.java | 7 ------- .../ui/fragments/preference/GeneralPreferenceFragment.java | 7 ------- .../sailing/racecommittee/app/ui/views/PanelButton.java | 1 - .../com/sap/sailing/racecommittee/app/utils/QRHelper.java | 5 ++--- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java index 14b8aed4f28..c0feda19177 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/LoginOnboarding.java @@ -4,10 +4,8 @@ import android.app.Activity; import android.app.Fragment; import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.AlertDialog; import android.text.SpannableString; @@ -28,11 +26,6 @@ import com.sap.sailing.racecommittee.app.AppConstants; import com.sap.sailing.racecommittee.app.AppPreferences; import com.sap.sailing.racecommittee.app.R; import com.sap.sailing.racecommittee.app.utils.QRHelper; -import com.sap.sailing.racecommittee.app.utils.UrlHelper; -import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; -import com.sap.sse.common.Util; - -import java.net.URL; public class LoginOnboarding extends Fragment { diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java index e1335d2e904..7f9ea488ee7 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/GeneralPreferenceFragment.java @@ -1,10 +1,7 @@ package com.sap.sailing.racecommittee.app.ui.fragments.preference; -import java.net.URL; - import android.app.Activity; import android.content.Intent; -import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.preference.CheckBoxPreference; @@ -13,21 +10,17 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; -import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.support.v7.app.AlertDialog; import android.widget.Toast; import com.sap.sailing.android.shared.ui.fragments.preference.BasePreferenceFragment; import com.sap.sailing.android.shared.ui.views.EditSetPreference; -import com.sap.sailing.domain.common.impl.DeviceConfigurationQRCodeUtils; import com.sap.sailing.racecommittee.app.AppPreferences; import com.sap.sailing.racecommittee.app.BuildConfig; import com.sap.sailing.racecommittee.app.R; import com.sap.sailing.racecommittee.app.utils.QRHelper; -import com.sap.sailing.racecommittee.app.utils.UrlHelper; import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; -import com.sap.sse.common.Util; public class GeneralPreferenceFragment extends BasePreferenceFragment { diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/PanelButton.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/PanelButton.java index a319126493b..7832810898f 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/PanelButton.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/PanelButton.java @@ -9,7 +9,6 @@ import android.support.annotation.StringRes; import android.support.v7.app.AlertDialog; import android.util.AttributeSet; import android.view.View; -import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.Switch; diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java index f4e755b6722..136aa1c36d7 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/QRHelper.java @@ -1,6 +1,7 @@ package com.sap.sailing.racecommittee.app.utils; -import android.app.Activity; +import java.net.URL; + import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; @@ -11,8 +12,6 @@ import com.sap.sailing.racecommittee.app.R; import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater; import com.sap.sse.common.Util; -import java.net.URL; - public class QRHelper { private Context mContext; From 716c68e1161e635aaa9ad32b2f0d86aff120194f Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 8 Mar 2016 13:55:19 +0100 Subject: [PATCH 003/178] Added debug ids for easier access to UI elements in selenium test cases --- .../sapheader/SAPHeaderWithAuthentication.java | 1 + .../ui/authentication/signin/SignInViewImpl.java | 11 ++++++++++- .../view/AbstractFlyoutAuthenticationView.java | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java index 4707a6472ae..93422ce0ce7 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java @@ -33,6 +33,7 @@ public class SAPHeaderWithAuthentication extends SAPHeader { rightWithAuthentication.addStyleName(res.css().header_right_wrapper()); Anchor authenticationMenu = new Anchor(); + authenticationMenu.ensureDebugId("authenticationMenu"); authenticationMenu.addStyleName(res.css().usermanagement_icon()); rightWithAuthentication.add(authenticationMenu); authenticationMenuView = new AuthenticationMenuViewImpl(authenticationMenu, res.css().usermanagement_loggedin(), res.css().usermanagement_open()); diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/signin/SignInViewImpl.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/signin/SignInViewImpl.java index be2bc4f2fd6..575a87b356f 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/signin/SignInViewImpl.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/signin/SignInViewImpl.java @@ -43,7 +43,7 @@ public class SignInViewImpl extends Composite implements SignInView { this.res = resources; UserManagementResources.INSTANCE.css().ensureInjected(); initWidget(uiBinder.createAndBindUi(this)); - + this.ensureDebugIds(); // TODO implement social login functionality socialLoginUi.removeFromParent(); } @@ -105,4 +105,13 @@ public class SignInViewImpl extends Composite implements SignInView { textBox.selectAll(); } + private void ensureDebugIds() { + ensureDebugId("signInForm"); + loginNameUi.ensureDebugId("loginTextField"); + passwordUi.ensureDebugId("passwordTextField"); + signInUi.ensureDebugId("signInAnchor"); + createAccountUi.ensureDebugId("signUpAnchor"); + forgotPasswordUi.ensureDebugId("forgotPasswordAnchor"); + } + } diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AbstractFlyoutAuthenticationView.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AbstractFlyoutAuthenticationView.java index ddd82b132fa..c116e06ab07 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AbstractFlyoutAuthenticationView.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AbstractFlyoutAuthenticationView.java @@ -46,6 +46,7 @@ public abstract class AbstractFlyoutAuthenticationView implements FlyoutAuthenti public AbstractFlyoutAuthenticationView(CommonSharedResources res) { this.res = res; LOCAL_CSS.ensureInjected(); + popupPanel.ensureDebugId("authenticationView"); popupPanel.addStyleName(LOCAL_CSS.flyover()); popupPanel.setWidget(uiBinder.createAndBindUi(this)); From c9a4b586bbec5f98867acc9cc411bec2d27db292 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 8 Mar 2016 13:56:20 +0100 Subject: [PATCH 004/178] Added interface for host pages to authentication functionality --- .../selenium/pages/PageWithAuthentication.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java new file mode 100644 index 00000000000..8bbc56b607a --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java @@ -0,0 +1,17 @@ +package com.sap.sailing.selenium.pages; + +import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; + +/** + * Marks a {@link HostPage} to have a menu for user authentication. + */ +public interface PageWithAuthentication { + + /** + * Access the pages {@link AuthenticationMenuPO authentication menu}. + * + * @return the pages {@link AuthenticationMenuPO authentication menu} handle + */ + AuthenticationMenuPO getAuthenticationMenu(); + +} From 7b80e041e13c179928614bd16d6ed8abd0cb20b7 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 8 Mar 2016 14:04:47 +0100 Subject: [PATCH 005/178] Added pages objects for authentication menu and view and sign in form --- .../authentication/AuthenticationMenuPO.java | 32 +++++++++++++ .../authentication/AuthenticationViewPO.java | 27 +++++++++++ .../pages/authentication/SignInViewPO.java | 46 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationViewPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java new file mode 100644 index 00000000000..3d389dd03ba --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java @@ -0,0 +1,32 @@ +package com.sap.sailing.selenium.pages.authentication; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageArea; +import com.sap.sailing.selenium.pages.common.CSSHelper; + +public class AuthenticationMenuPO extends PageArea { + + private static final String CSS_CLASS_PREFIX = "com-sap-sse-security-ui-authentication-generic-sapheader-SAPHeaderWithAuthenticationResources-HeaderWithAuthenticationCss-"; + private static final String CSS_CLASS_OPEN = CSS_CLASS_PREFIX + "usermanagement_open"; + private static final String CSS_CLASS_LOGGED_IN = CSS_CLASS_PREFIX + "usermanagement_loggedin"; + + public AuthenticationMenuPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public boolean isOpen() { + return CSSHelper.hasCSSClass(getWebElement(), CSS_CLASS_OPEN); + } + + public boolean isLoggedIn() { + return CSSHelper.hasCSSClass(getWebElement(), CSS_CLASS_LOGGED_IN); + } + + public AuthenticationViewPO showAuthenticationView() { + getWebElement().click(); + return new AuthenticationViewPO(driver, findElementBySeleniumId(driver, "authenticationView")); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationViewPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationViewPO.java new file mode 100644 index 00000000000..a50df9e7bc0 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationViewPO.java @@ -0,0 +1,27 @@ +package com.sap.sailing.selenium.pages.authentication; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.core.BySeleniumId; +import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.PageArea; + +public class AuthenticationViewPO extends PageArea { + + @FindBy(how = BySeleniumId.class, using = "signInForm") + private WebElement signInFormPanel; + + public AuthenticationViewPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public boolean isSignInFormDisplayed() { + return signInFormPanel != null && signInFormPanel.isDisplayed(); + } + + public SignInViewPO getSignInView() { + if (!isSignInFormDisplayed()) throw new RuntimeException("Sign in form not displayed!"); + return new SignInViewPO(driver, signInFormPanel); + } +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java new file mode 100644 index 00000000000..79cba933dc8 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java @@ -0,0 +1,46 @@ +package com.sap.sailing.selenium.pages.authentication; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.core.BySeleniumId; +import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.PageArea; + +public class SignInViewPO extends PageArea { + + @FindBy(how = BySeleniumId.class, using = "loginTextField") + private WebElement loginTextField; + + @FindBy(how = BySeleniumId.class, using = "passwordTextField") + private WebElement passwordTextField; + + @FindBy(how = BySeleniumId.class, using = "signInAnchor") + private WebElement signInAnchor; + + @FindBy(how = BySeleniumId.class, using = "signUpAnchor") + private WebElement signUpAnchor; + + @FindBy(how = BySeleniumId.class, using = "forgotPasswordAnchor") + private WebElement forgotPasswordAnchor; + + public SignInViewPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public void doLogin(String username, String password) { + loginTextField.clear(); + loginTextField.sendKeys(username); + passwordTextField.clear(); + passwordTextField.sendKeys(password); + signInAnchor.click(); + } + + public void goToSignUpView() { + signUpAnchor.click(); + } + + public void goToForgotPasswordView() { + forgotPasswordAnchor.click(); + } +} From f0a730fc68274f5d00588a2aa60c9288ef810860 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 8 Mar 2016 14:05:46 +0100 Subject: [PATCH 006/178] Extended AdminConsole host page to provide access to the authentication menu --- .../pages/adminconsole/AdminConsolePage.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java index 507c762dd5b..b758f3b03f2 100755 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java @@ -15,6 +15,7 @@ import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.ElementSearchConditions; import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.pages.HostPage; +import com.sap.sailing.selenium.pages.PageWithAuthentication; import com.sap.sailing.selenium.pages.adminconsole.connectors.SmartphoneTrackingEventManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardGroupConfigurationPanelPO; @@ -22,6 +23,7 @@ import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManag import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesCompetitorsPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanelPO; +import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; /** *

The page object representing the administration console. The console consists of multiple tabs with its content @@ -30,7 +32,7 @@ import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagem * @author * D049941 */ -public class AdminConsolePage extends HostPage { +public class AdminConsolePage extends HostPage implements PageWithAuthentication { private static final Logger logger = Logger.getLogger(AdminConsolePage.class.getName()); private static final String PAGE_TITLE = "SAP Sailing Analytics Administration Console"; //$NON-NLS-1$ @@ -87,6 +89,9 @@ public class AdminConsolePage extends HostPage { @FindBy(how = BySeleniumId.class, using = "AdministrationTabs") private WebElement administrationTabPanel; + @FindBy(how = BySeleniumId.class, using = "authenticationMenu") + private WebElement authenticationMenuAnchor; + private AdminConsolePage(WebDriver driver) { super(driver); } @@ -139,6 +144,11 @@ public class AdminConsolePage extends HostPage { SMARTPHONETRACKINGPANEL_PANEL_TAB_IDENTIFIER, false)); } + @Override + public AuthenticationMenuPO getAuthenticationMenu() { + return new AuthenticationMenuPO(driver, authenticationMenuAnchor); + } + /** *

Verifies that the current page is the administration console by checking the title of the page.

*/ From e17d5e88e00a62aa5dac0fde372f045256e12342 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 8 Mar 2016 14:13:09 +0100 Subject: [PATCH 007/178] Added selenium test case for sign in with existing admin user --- .../TestAuthenticationSignIn.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java new file mode 100644 index 00000000000..13601f69e3f --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java @@ -0,0 +1,36 @@ +package com.sap.sailing.selenium.test.authentication; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; +import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; +import com.sap.sailing.selenium.pages.authentication.AuthenticationViewPO; +import com.sap.sailing.selenium.test.AbstractSeleniumTest; + +public class TestAuthenticationSignIn extends AbstractSeleniumTest { + + @Override + @Before + public void setUp() { + clearState(getContextRoot()); + } + + @Test + public void testSignInWithExistingUserAdmin() { + AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); + AuthenticationMenuPO authenticationMenu = adminConsolePage.getAuthenticationMenu(); + assertFalse(authenticationMenu.isOpen()); + assertFalse(authenticationMenu.isLoggedIn()); + AuthenticationViewPO authenticationView = authenticationMenu.showAuthenticationView(); + assertTrue(authenticationMenu.isOpen()); + assertFalse(authenticationMenu.isLoggedIn()); + authenticationView.getSignInView().doLogin("admin", "admin"); + assertTrue(authenticationMenu.isOpen()); + assertTrue(authenticationMenu.isLoggedIn()); + } + +} From 1428a836cceab08dc4fc74e7f5362c49d6406902 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 11:17:17 +0100 Subject: [PATCH 008/178] Replaced css class based state verification to a data attribute based approach --- .../pages/authentication/AuthenticationMenuPO.java | 10 +++------- .../generic/sapheader/SAPHeaderWithAuthentication.java | 1 - .../view/AuthenticationMenuViewImpl.java | 10 ++++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java index 3d389dd03ba..1e30b047c9e 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java @@ -4,24 +4,20 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import com.sap.sailing.selenium.pages.PageArea; -import com.sap.sailing.selenium.pages.common.CSSHelper; +import com.sap.sailing.selenium.pages.common.AttributeHelper; public class AuthenticationMenuPO extends PageArea { - private static final String CSS_CLASS_PREFIX = "com-sap-sse-security-ui-authentication-generic-sapheader-SAPHeaderWithAuthenticationResources-HeaderWithAuthenticationCss-"; - private static final String CSS_CLASS_OPEN = CSS_CLASS_PREFIX + "usermanagement_open"; - private static final String CSS_CLASS_LOGGED_IN = CSS_CLASS_PREFIX + "usermanagement_loggedin"; - public AuthenticationMenuPO(WebDriver driver, WebElement element) { super(driver, element); } public boolean isOpen() { - return CSSHelper.hasCSSClass(getWebElement(), CSS_CLASS_OPEN); + return AttributeHelper.isEnabled(getWebElement(), "data-open"); } public boolean isLoggedIn() { - return CSSHelper.hasCSSClass(getWebElement(), CSS_CLASS_LOGGED_IN); + return AttributeHelper.isEnabled(getWebElement(), "data-auth"); } public AuthenticationViewPO showAuthenticationView() { diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java index 93422ce0ce7..4707a6472ae 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/generic/sapheader/SAPHeaderWithAuthentication.java @@ -33,7 +33,6 @@ public class SAPHeaderWithAuthentication extends SAPHeader { rightWithAuthentication.addStyleName(res.css().header_right_wrapper()); Anchor authenticationMenu = new Anchor(); - authenticationMenu.ensureDebugId("authenticationMenu"); authenticationMenu.addStyleName(res.css().usermanagement_icon()); rightWithAuthentication.add(authenticationMenu); authenticationMenuView = new AuthenticationMenuViewImpl(authenticationMenu, res.css().usermanagement_loggedin(), res.css().usermanagement_open()); diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AuthenticationMenuViewImpl.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AuthenticationMenuViewImpl.java index c00f7f0077e..403019c175c 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AuthenticationMenuViewImpl.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/authentication/view/AuthenticationMenuViewImpl.java @@ -1,5 +1,6 @@ package com.sap.sse.security.ui.authentication.view; +import com.google.gwt.debug.client.DebugInfo; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Anchor; @@ -35,6 +36,7 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView { presenter.toggleFlyout(); } }); + this.anchor.ensureDebugId("authenticationMenu"); } @Override @@ -50,11 +52,19 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView { @Override public void setAuthenticated(boolean authenticated) { anchor.setStyleName(loggedInStyle, authenticated); + setDebugDataAttribute("data-auth", authenticated); } @Override public void setOpen(boolean open) { anchor.setStyleName(openStyle, open); + setDebugDataAttribute("data-open", open); + } + + private void setDebugDataAttribute(String name, boolean value) { + if (DebugInfo.isDebugIdEnabled()) { + anchor.getElement().setAttribute(name, String.valueOf(value)); + } } } From 4a97e8762058e2be449ec9cf1fc58d2e5d95a7d0 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 14:22:24 +0100 Subject: [PATCH 009/178] Adjusted condition for ajax calls complition check --- .../src/com/sap/sailing/selenium/core/AjaxCallsComplete.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/AjaxCallsComplete.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/AjaxCallsComplete.java index 2e311f9e2a7..4a8b2d0d89d 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/AjaxCallsComplete.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/AjaxCallsComplete.java @@ -25,7 +25,7 @@ public class AjaxCallsComplete implements ExpectedCondition { */ public static final String CATEGORY_GLOBAL = ""; //$NON-NLS-1$ - private static final String JAVASCRIPT = "return (window.PENDING_AJAX_CALLS.numberOfPendingCalls(arguments[0]) === 0)"; //$NON-NLS-1$ + private static final String JAVASCRIPT = "return window.PENDING_AJAX_CALLS && (window.PENDING_AJAX_CALLS.numberOfPendingCalls(arguments[0]) === 0)"; //$NON-NLS-1$ private String category; @@ -60,7 +60,7 @@ public class AjaxCallsComplete implements ExpectedCondition { JavascriptExecutor executor = (JavascriptExecutor) driver; boolean result = false; try { - result = (Boolean) executor.executeScript(JAVASCRIPT, this.category); + result = Boolean.TRUE.equals(executor.executeScript(JAVASCRIPT, this.category)); } catch (WebDriverException e) { logger.log(Level.WARNING, "Exception looking for PENDING_AJAX_CALLS variable. Telling caller that not all AJAX calls have finished yet.", e); } From bbbf4384383eb494145077864b69746c19d62d38 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 14:23:10 +0100 Subject: [PATCH 010/178] Added convenience methods for waitUntil checks to PageObject class --- .../com/sap/sailing/selenium/pages/PageObject.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java index 9c058aa723e..907dfc7246e 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java @@ -5,13 +5,16 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.function.BooleanSupplier; import org.openqa.selenium.SearchContext; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.FluentWait; +import org.openqa.selenium.support.ui.WebDriverWait; +import com.google.common.base.Predicate; import com.sap.sailing.selenium.core.AjaxCallsComplete; import com.sap.sailing.selenium.core.AjaxCallsExecuted; import com.sap.sailing.selenium.core.BySeleniumId; @@ -389,7 +392,15 @@ public class PageObject { protected void waitForAjaxRequestsExecuted(String category, int numberOfCalls, int timeout, int polling) { FluentWait wait = createFluentWait(this.driver, timeout, polling); - wait.until(new AjaxCallsExecuted(category, numberOfCalls)); } + + protected void waitUtil(Predicate predicate) { + WebDriverWait webDriverWait = new WebDriverWait(driver, DEFAULT_LOOKUP_TIMEOUT); + webDriverWait.until(predicate); + } + + protected void waitUtil(BooleanSupplier supplier) { + waitUtil((driver) -> supplier.getAsBoolean()); + } } From 1c6c375921de4299942c9790331fb5cfe8bd0574 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 14:25:31 +0100 Subject: [PATCH 011/178] Refactored selenium test case for sign in with existing admin user --- .../pages/HostPageWithAuthentication.java | 28 +++++++++++++++++++ .../pages/PageWithAuthentication.java | 17 ----------- .../pages/adminconsole/AdminConsolePage.java | 14 ++-------- .../authentication/AuthenticationMenuPO.java | 9 +++++- .../pages/authentication/SignInViewPO.java | 8 +++--- .../TestAuthenticationSignIn.java | 6 +--- 6 files changed, 43 insertions(+), 39 deletions(-) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPageWithAuthentication.java delete mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPageWithAuthentication.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPageWithAuthentication.java new file mode 100644 index 00000000000..f0cf27237f9 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPageWithAuthentication.java @@ -0,0 +1,28 @@ +package com.sap.sailing.selenium.pages; + +import org.openqa.selenium.WebDriver; + +import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; + +/** + * Extended {@link HostPage} implementation which provides user authentication. + */ +public class HostPageWithAuthentication extends HostPage { + + /** + * @see HostPage#HostPage(WebDriver) + */ + public HostPageWithAuthentication(WebDriver driver) { + super(driver); + } + + /** + * Access the pages {@link AuthenticationMenuPO authentication menu}. + * + * @return the pages {@link AuthenticationMenuPO authentication menu} handle + */ + public AuthenticationMenuPO getAuthenticationMenu() { + return new AuthenticationMenuPO(driver, findElementBySeleniumId("authenticationMenu")); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java deleted file mode 100644 index 8bbc56b607a..00000000000 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageWithAuthentication.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.sap.sailing.selenium.pages; - -import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; - -/** - * Marks a {@link HostPage} to have a menu for user authentication. - */ -public interface PageWithAuthentication { - - /** - * Access the pages {@link AuthenticationMenuPO authentication menu}. - * - * @return the pages {@link AuthenticationMenuPO authentication menu} handle - */ - AuthenticationMenuPO getAuthenticationMenu(); - -} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java index b758f3b03f2..8bd65b6c339 100755 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java @@ -14,8 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.ElementSearchConditions; import com.sap.sailing.selenium.core.FindBy; -import com.sap.sailing.selenium.pages.HostPage; -import com.sap.sailing.selenium.pages.PageWithAuthentication; +import com.sap.sailing.selenium.pages.HostPageWithAuthentication; import com.sap.sailing.selenium.pages.adminconsole.connectors.SmartphoneTrackingEventManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardGroupConfigurationPanelPO; @@ -23,7 +22,6 @@ import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManag import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesCompetitorsPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanelPO; -import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; /** *

The page object representing the administration console. The console consists of multiple tabs with its content @@ -32,7 +30,7 @@ import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; * @author * D049941 */ -public class AdminConsolePage extends HostPage implements PageWithAuthentication { +public class AdminConsolePage extends HostPageWithAuthentication { private static final Logger logger = Logger.getLogger(AdminConsolePage.class.getName()); private static final String PAGE_TITLE = "SAP Sailing Analytics Administration Console"; //$NON-NLS-1$ @@ -89,9 +87,6 @@ public class AdminConsolePage extends HostPage implements PageWithAuthentication @FindBy(how = BySeleniumId.class, using = "AdministrationTabs") private WebElement administrationTabPanel; - @FindBy(how = BySeleniumId.class, using = "authenticationMenu") - private WebElement authenticationMenuAnchor; - private AdminConsolePage(WebDriver driver) { super(driver); } @@ -144,11 +139,6 @@ public class AdminConsolePage extends HostPage implements PageWithAuthentication SMARTPHONETRACKINGPANEL_PANEL_TAB_IDENTIFIER, false)); } - @Override - public AuthenticationMenuPO getAuthenticationMenu() { - return new AuthenticationMenuPO(driver, authenticationMenuAnchor); - } - /** *

Verifies that the current page is the administration console by checking the title of the page.

*/ diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java index 1e30b047c9e..aba8b187cd9 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java @@ -20,8 +20,15 @@ public class AuthenticationMenuPO extends PageArea { return AttributeHelper.isEnabled(getWebElement(), "data-auth"); } - public AuthenticationViewPO showAuthenticationView() { + public void doLogin(String username, String password) { + AuthenticationViewPO authenticationView = showAuthenticationView(); + authenticationView.getSignInView().doLogin(username, password); + waitUtil(this::isLoggedIn); + } + + private AuthenticationViewPO showAuthenticationView() { getWebElement().click(); + waitUtil(this::isOpen); return new AuthenticationViewPO(driver, findElementBySeleniumId(driver, "authenticationView")); } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java index 79cba933dc8..02cb9e43590 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/SignInViewPO.java @@ -24,11 +24,11 @@ public class SignInViewPO extends PageArea { @FindBy(how = BySeleniumId.class, using = "forgotPasswordAnchor") private WebElement forgotPasswordAnchor; - public SignInViewPO(WebDriver driver, WebElement element) { + SignInViewPO(WebDriver driver, WebElement element) { super(driver, element); } - public void doLogin(String username, String password) { + void doLogin(String username, String password) { loginTextField.clear(); loginTextField.sendKeys(username); passwordTextField.clear(); @@ -36,11 +36,11 @@ public class SignInViewPO extends PageArea { signInAnchor.click(); } - public void goToSignUpView() { + void goToSignUpView() { signUpAnchor.click(); } - public void goToForgotPasswordView() { + void goToForgotPasswordView() { forgotPasswordAnchor.click(); } } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java index 13601f69e3f..c6ab6b4b44d 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/authentication/TestAuthenticationSignIn.java @@ -8,7 +8,6 @@ import org.junit.Test; import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; import com.sap.sailing.selenium.pages.authentication.AuthenticationMenuPO; -import com.sap.sailing.selenium.pages.authentication.AuthenticationViewPO; import com.sap.sailing.selenium.test.AbstractSeleniumTest; public class TestAuthenticationSignIn extends AbstractSeleniumTest { @@ -25,10 +24,7 @@ public class TestAuthenticationSignIn extends AbstractSeleniumTest { AuthenticationMenuPO authenticationMenu = adminConsolePage.getAuthenticationMenu(); assertFalse(authenticationMenu.isOpen()); assertFalse(authenticationMenu.isLoggedIn()); - AuthenticationViewPO authenticationView = authenticationMenu.showAuthenticationView(); - assertTrue(authenticationMenu.isOpen()); - assertFalse(authenticationMenu.isLoggedIn()); - authenticationView.getSignInView().doLogin("admin", "admin"); + authenticationMenu.doLogin("admin", "admin"); assertTrue(authenticationMenu.isOpen()); assertTrue(authenticationMenu.isLoggedIn()); } From ef9a3d424c329cd7c742a2b758f1e95b9beffe21 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 18:03:50 +0100 Subject: [PATCH 012/178] Added debug ids for easier access to UI elements in selenium test cases --- .../gwt/ui/adminconsole/AdminConsoleEntryPoint.java | 1 + .../sailing/gwt/ui/adminconsole/EventCreateDialog.java | 8 +++++++- .../sailing/gwt/ui/adminconsole/EventListComposite.java | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AdminConsoleEntryPoint.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AdminConsoleEntryPoint.java index b214a68dd41..983f752fb84 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AdminConsoleEntryPoint.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AdminConsoleEntryPoint.java @@ -93,6 +93,7 @@ public class AdminConsoleEntryPoint extends AbstractSailingEntryPoint implements leaderboardGroupsDisplayers = new HashSet<>(); final EventManagementPanel eventManagementPanel = new EventManagementPanel(sailingService, this, this, getStringMessages()); + eventManagementPanel.ensureDebugId("EventManagement"); panel.addToVerticalTabPanel(new DefaultRefreshableAdminConsolePanel(eventManagementPanel) { @Override public void refreshAfterBecomingVisible() { diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventCreateDialog.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventCreateDialog.java index f472748b084..51c16288695 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventCreateDialog.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventCreateDialog.java @@ -20,22 +20,28 @@ public class EventCreateDialog extends EventDialog { availableLeaderboardGroups, /* leaderboardGroups */ Collections.emptyList(), callback); nameEntryField = createTextBox(null); nameEntryField.setVisibleLength(50); + nameEntryField.ensureDebugId("NameTextBox"); descriptionEntryField = createTextArea(null); descriptionEntryField.setCharacterWidth(50); descriptionEntryField.setVisibleLines(2); descriptionEntryField.getElement().getStyle().setProperty("resize", "none"); + descriptionEntryField.ensureDebugId("DescriptionTextArea"); venueEntryField = createTextBox(null); venueEntryField.setVisibleLength(35); + venueEntryField.ensureDebugId("VenueTextBox"); final Date now = new Date(); startDateBox = createDateTimeBox(now); - startDateBox.setFormat("dd/mm/yyyy hh:ii"); + startDateBox.setFormat("dd/mm/yyyy hh:ii"); + startDateBox.ensureDebugId("StartDateTimeBox"); endDateBox = createDateTimeBox(now); endDateBox.setFormat("dd/mm/yyyy hh:ii"); + endDateBox.ensureDebugId("EndDateTimeBox"); officialWebsiteURLEntryField = createTextBox(null); officialWebsiteURLEntryField.setVisibleLength(50); sailorsInfoWebsiteURLEntryFields = createTextBoxesForLocalesAndDefault(Collections. emptyMap()); isPublicCheckBox = createCheckbox(""); isPublicCheckBox.setValue(false); + isPublicCheckBox.ensureDebugId("IsPublicCheckBox"); imagesListComposite.fillImages(Collections.emptyList()); videosListComposite.fillVideos(Collections.emptyList()); // add default course area diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java index ea7b3bee298..7ec6d7471b3 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java @@ -118,6 +118,7 @@ public class EventListComposite extends Composite implements EventsRefresher, Le panel.add(eventControlsPanel); Button refreshButton = new Button(stringMessages.refresh()); + refreshButton.ensureDebugId("RefreshEventsButton"); refreshButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { @@ -127,6 +128,7 @@ public class EventListComposite extends Composite implements EventsRefresher, Le eventControlsPanel.add(refreshButton); Button createEventBtn = new Button(stringMessages.actionAddEvent()); + createEventBtn.ensureDebugId("CreateEventButton"); createEventBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { @@ -136,6 +138,7 @@ public class EventListComposite extends Composite implements EventsRefresher, Le eventControlsPanel.add(createEventBtn); removeEventsButton = new Button(stringMessages.remove()); + removeEventsButton.ensureDebugId("RemoveEventsButton"); removeEventsButton.setEnabled(false); removeEventsButton.addClickHandler(new ClickHandler() { @Override @@ -455,6 +458,7 @@ public class EventListComposite extends Composite implements EventsRefresher, Le createNewEvent(newEvent, existingLeaderboardGroups); } }); + dialog.ensureDebugId("EventCreateDialog"); dialog.show(); } From 38f4518f4adaf432d7c051a53a793b5d4a2d2a80 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 18:05:49 +0100 Subject: [PATCH 013/178] Added pages objects for event config panel and creation dialog --- .../event/EventConfigurationPanelPO.java | 33 +++++++++++ .../event/EventCreateDialogPO.java | 57 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java new file mode 100644 index 00000000000..3e0be4d7c63 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -0,0 +1,33 @@ +package com.sap.sailing.selenium.pages.adminconsole.event; + +import java.util.Date; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.core.BySeleniumId; +import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.PageArea; + +public class EventConfigurationPanelPO extends PageArea { + + @FindBy(how = BySeleniumId.class, using = "RefreshEventsButton") + private WebElement refreshEventsButton; + + @FindBy(how = BySeleniumId.class, using = "CreateEventButton") + private WebElement createEventButton; + + @FindBy(how = BySeleniumId.class, using = "RemoveEventsButton") + private WebElement removeEventsButton; + + public EventConfigurationPanelPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public void createPublicEvent(String name, String venue, Date startDate, Date endDate) { + createEventButton.click(); + EventCreateDialogPO dialog = new EventCreateDialogPO(driver, findElementBySeleniumId(driver, "EventCreateDialog")); + dialog.createEvent(name, "", venue, startDate, endDate, true); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java new file mode 100644 index 00000000000..15fa7a9b574 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java @@ -0,0 +1,57 @@ +package com.sap.sailing.selenium.pages.adminconsole.event; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.core.BySeleniumId; +import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.common.DataEntryDialogPO; +import com.sap.sailing.selenium.pages.gwt.CheckBoxPO; + +public class EventCreateDialogPO extends DataEntryDialogPO { + + private static final DateFormat DATE_TIME_BOX_FORMAT = new SimpleDateFormat("dd/mm/yyyy hh:mm"); + + @FindBy(how = BySeleniumId.class, using = "NameTextBox") + private WebElement nameTextBox; + + @FindBy(how = BySeleniumId.class, using = "DescriptionTextArea") + private WebElement descriptionTextArea; + + @FindBy(how = BySeleniumId.class, using = "VenueTextBox") + private WebElement venueTextBox; + + @FindBy(how = BySeleniumId.class, using = "StartDateTimeBox") + private WebElement startDateTimeBox; + + @FindBy(how = BySeleniumId.class, using = "EndDateTimeBox") + private WebElement endDateTimeBox; + + @FindBy(how = BySeleniumId.class, using = "IsPublicCheckBox") + private WebElement isPublicCheckBox; + + EventCreateDialogPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + void createEvent(String name, String description, String venue, Date start, Date end, boolean isPublic) { + setTextValue(nameTextBox, name); + setTextValue(descriptionTextArea, description); + setTextValue(venueTextBox, venue); + setTextValue(startDateTimeBox, DATE_TIME_BOX_FORMAT.format(start)); + setTextValue(endDateTimeBox, DATE_TIME_BOX_FORMAT.format(end)); + CheckBoxPO checkBox = new CheckBoxPO(driver, isPublicCheckBox); + checkBox.setSelected(isPublic); + pressOk(); + } + + private void setTextValue(WebElement webElement, String value) { + webElement.clear(); + webElement.sendKeys(value); + } + +} From d05b2b1cc7ba15d2f10febe7b1e87286024e94ba Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 18:06:33 +0100 Subject: [PATCH 014/178] Added Events tab navigation to AdminConsole page object --- .../selenium/pages/adminconsole/AdminConsolePage.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java index 8bd65b6c339..544f0c855c4 100755 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java @@ -16,6 +16,7 @@ import com.sap.sailing.selenium.core.ElementSearchConditions; import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.pages.HostPageWithAuthentication; import com.sap.sailing.selenium.pages.adminconsole.connectors.SmartphoneTrackingEventManagementPanelPO; +import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardGroupConfigurationPanelPO; import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManagementPanelPO; @@ -40,6 +41,9 @@ public class AdminConsolePage extends HostPageWithAuthentication { private static final MessageFormat VERTICAL_TAB_EXPRESSION = new MessageFormat( ".//div[contains(@class, \"gwt-VerticalTabLayoutPanelTabInner\")]/div[text()=\"{0}\"]/../.."); + private static final String EVENTS_TAB_LABEL = "Events"; //$NON-NLS-1$ + private static final String EVENTS_TAB_IDENTIFIER = "EventManagement"; //$NON-NLS-1$ + private static final String REGATTA_STRUCTURE_TAB_LABEL = "Regattas"; //$NON-NLS-1$ private static final String REGATTA_STRUCTURE_TAB_IDENTIFIER = "RegattaStructureManagement"; //$NON-NLS-1$ @@ -91,6 +95,10 @@ public class AdminConsolePage extends HostPageWithAuthentication { super(driver); } + public EventConfigurationPanelPO goToEvents() { + return new EventConfigurationPanelPO(this.driver, goToTab(EVENTS_TAB_LABEL, EVENTS_TAB_IDENTIFIER, true)); + } + public RegattaStructureManagementPanelPO goToRegattaStructure() { return new RegattaStructureManagementPanelPO(this.driver, goToTab(REGATTA_STRUCTURE_TAB_LABEL, REGATTA_STRUCTURE_TAB_IDENTIFIER, true)); From 78d7a4e613c60e5b1c81f326513e3148e0af02ae Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Wed, 9 Mar 2016 18:07:06 +0100 Subject: [PATCH 015/178] Added selenium test stub for event state visualisation --- .../state/TestStateVisualisationEvent.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java new file mode 100644 index 00000000000..230f9829e44 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java @@ -0,0 +1,28 @@ +package com.sap.sailing.selenium.test.integration.state; + +import java.util.Date; + +import org.junit.Assert; +import org.junit.Test; + +import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; +import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; +import com.sap.sailing.selenium.test.AbstractSeleniumTest; + +public class TestStateVisualisationEvent extends AbstractSeleniumTest { + + @Override + public void setUp() { + clearState(getContextRoot()); + super.setUp(); + } + + @Test + public void testStateFlagOfUmcomingEvent() { + AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); + EventConfigurationPanelPO eventConfigurationPanel = adminConsolePage.goToEvents(); + eventConfigurationPanel.createPublicEvent("Test", "Somewhere", new Date(), new Date()); + Assert.assertTrue(true); + } + +} From c5fc5d87bba7738bfeb0f6e72d975aa7ca8e294e Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 13:48:06 +0100 Subject: [PATCH 016/178] Refactored structure of page objects representing GWT inputs --- .../selenium/pages/gwt/AbstractInputPO.java | 72 ++++++++++++++++++ .../pages/gwt/BetterDateTimeBoxPO.java | 37 ++++++++++ .../selenium/pages/gwt/CheckBoxPO.java | 73 +++++++++++++------ .../selenium/pages/gwt/TextAreaPO.java | 44 +++++++++++ .../selenium/pages/gwt/TextBoxBasePO.java | 55 ++++++++++++++ .../sailing/selenium/pages/gwt/TextBoxPO.java | 44 +++++++++++ 6 files changed, 304 insertions(+), 21 deletions(-) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/AbstractInputPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextAreaPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxPO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/AbstractInputPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/AbstractInputPO.java new file mode 100644 index 00000000000..fb67f695729 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/AbstractInputPO.java @@ -0,0 +1,72 @@ +package com.sap.sailing.selenium.pages.gwt; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageArea; +import com.sap.sailing.selenium.pages.PageObject; +import com.sap.sailing.selenium.pages.common.CSSHelper; + +/** + * Abstract super class for {@link PageObject}s representing a (GWT) UI element, which verifies the provided + * {@link WebElement} by the tag name and CSS class name defined in implementing subclasses. + */ +public abstract class AbstractInputPO extends PageArea { + + /** + * @see PageArea#PageArea(WebDriver, WebElement) + */ + protected AbstractInputPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + /** + * Verifies that the underlying {@link WebElement} is represented by the defined {@link #getTagName() tag name} and + * has (at least) the defined {@link #getCssClassName() CSS class name}. + * + * @throws IllegalArgumentException + * if the {@link WebElement}s tag name does not match the defined tag name or if the it doesn't have the + * defined CSS class name + * + * @see #getTagName() + * @see #getClass() + */ + @Override + protected void verify() { + WebElement element = getWebElement(); + String tagName = element.getTagName(); + if(!getTagName().equalsIgnoreCase(tagName) || !CSSHelper.hasCSSClass(element, getCssClassName())) { + throw new IllegalArgumentException("WebElement does not represent a " + getCssClassName()); + } + } + + /** + * Determines whether or not the underlying {@link WebElement} is enabled. + * + * @return true if the {@link WebElement} is enabled, false otherwise + * + * @see WebElement#isEnabled() + */ + public boolean isEnabled() { + return getWebElement().isEnabled(); + } + + /** + * Provide a tag name used for verification. + * + * @return the elements tag name + * + * @see #verify() + */ + protected abstract String getTagName(); + + /** + * Provide a CSS class name used for verification. + * + * @return the elements (primary) CSS class name + * + * @see #verify() + */ + protected abstract String getCssClassName(); + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java new file mode 100644 index 00000000000..93abfa5462c --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java @@ -0,0 +1,37 @@ +package com.sap.sailing.selenium.pages.gwt; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageObject; + +/** + * {@link PageObject} implementation for better date time boxes. + */ +public class BetterDateTimeBoxPO extends TextBoxPO { + + /** + * Factory method to create a {@link BetterDateTimeBoxPO}. + * + * @param driver the web driver to use + * @param element the element representing the date time box on the page + * @return a new {@link BetterDateTimeBoxPO} instance + */ + public static BetterDateTimeBoxPO create(WebDriver driver, WebElement element) { + return new BetterDateTimeBoxPO(driver, element); + } + + /** + * @see TextBoxPO#TextBoxPO(WebDriver, WebElement) + */ + protected BetterDateTimeBoxPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + @Override + public void appendText(String text) { + super.appendText(text); + super.appendText("\t"); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java index defe9811517..28c00b5c4ed 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java @@ -5,14 +5,15 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.PageObject; -import com.sap.sailing.selenium.pages.PageArea; -import com.sap.sailing.selenium.pages.common.CSSHelper; - -public class CheckBoxPO extends PageArea { - protected static final String TAG_NAME = "span"; //$NON-NLS-1$ +/** + * {@link PageObject} implementation for GWT check boxes. + */ +public class CheckBoxPO extends AbstractInputPO { - private static final String CHECKBOX_CSS_CLASS = "gwt-CheckBox"; + private static final String TAG_NAME = "span"; + private static final String CSS_CLASS = "gwt-CheckBox"; @FindBy(how = ByTagName.class, using = "input") private WebElement input; @@ -20,37 +21,67 @@ public class CheckBoxPO extends PageArea { @FindBy(how = ByTagName.class, using = "label") private WebElement label; + /** + * Factory method to create a {@link CheckBoxPO}. + * + * @param driver the web driver to use + * @param element the element representing the check box on the page + * @return a new {@link CheckBoxPO} instance + */ + public static CheckBoxPO create(WebDriver driver, WebElement element) { + return new CheckBoxPO(driver, element); + } + + /** + * @see AbstractInputPO#AbstractInputPO(WebDriver, WebElement) + */ public CheckBoxPO(WebDriver driver, WebElement element) { super(driver, element); } - - @Override - protected void verify() { - WebElement element = (WebElement) this.context; - String tagName = element.getTagName(); - - if(!TAG_NAME.equalsIgnoreCase(tagName) || !CSSHelper.hasCSSClass(element, getCssClassName())) - throw new IllegalArgumentException("WebElement does not represent a CheckBox"); - } - - public boolean isEnabled() { - return this.input.isEnabled(); - } + /** + * Get the text of the check boxes label. + * + * @return the label text + */ public String getLabel() { return this.label.getText(); } + /** + * Determines whether or not the underlying {@link WebElement} is selected. + * + * @return true if the {@link WebElement} is enabled, false otherwise + * + * @see WebElement#isSelected() + */ public boolean isSelected() { return this.input.isSelected(); } + /** + * Changes the {@link WebElement}s selection by clicking it, if desired and current state don't match. + * + * @param selected the desired selection state + */ public void setSelected(boolean selected) { - if(selected != isSelected()) + if(selected != isSelected()) { this.input.click(); + } } + @Override + public boolean isEnabled() { + return this.input.isEnabled(); + } + + @Override + protected String getTagName() { + return TAG_NAME; + } + + @Override protected String getCssClassName() { - return CHECKBOX_CSS_CLASS; + return CSS_CLASS; } } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextAreaPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextAreaPO.java new file mode 100644 index 00000000000..4fee7d855a9 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextAreaPO.java @@ -0,0 +1,44 @@ +package com.sap.sailing.selenium.pages.gwt; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageObject; + +/** + * {@link PageObject} implementation for GWT text areas. + */ +public class TextAreaPO extends TextBoxBasePO { + + private static final String TAG_NAME = "textarea"; + private static final String CSS_CLASS = "gwt-TextArea"; + + /** + * Factory method to create a {@link TextAreaPO}. + * + * @param driver the web driver to use + * @param element the element representing the text area on the page + * @return a new {@link TextAreaPO} instance + */ + public static TextAreaPO create(WebDriver driver, WebElement element) { + return new TextAreaPO(driver, element); + } + + /** + * @see TextBoxBasePO#TextBoxBasePO(WebDriver, WebElement) + */ + protected TextAreaPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + @Override + protected String getTagName() { + return TAG_NAME; + } + + @Override + protected String getCssClassName() { + return CSS_CLASS; + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java new file mode 100644 index 00000000000..1835366cb34 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java @@ -0,0 +1,55 @@ +package com.sap.sailing.selenium.pages.gwt; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageObject; + +/** + * Abstract base {@link PageObject} implementation for GWT text inputs, providing access to the contained text. + */ +public abstract class TextBoxBasePO extends AbstractInputPO { + + /** + * @see AbstractInputPO#AbstractInputPO(WebDriver, WebElement) + */ + protected TextBoxBasePO(WebDriver driver, WebElement element) { + super(driver, element); + } + + /** + * Appends the given text to the underlying {@link WebElement}, while keeping possibly existing text. + * + * @param text the text to append + * + * @see WebElement#sendKeys(CharSequence...) + */ + public void appendText(String text) { + getWebElement().sendKeys(text); + } + + /** + * Sets the given text to the underlying {@link WebElement}, while clearing possibly existing text. + * + * @param text the text to set + * + * @see WebElement#clear() + * @see WebElement#sendKeys(CharSequence...) + */ + public void setText(String text) { + getWebElement().clear(); + this.appendText(text); + } + + /** + * Gets the text contained in the underlying {@link WebElement}. + * + * @return the contained text + * + * @see WebElement#getText() + */ + public String getText() { + return getWebElement().getText(); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxPO.java new file mode 100644 index 00000000000..95496a8dc72 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxPO.java @@ -0,0 +1,44 @@ +package com.sap.sailing.selenium.pages.gwt; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageObject; + +/** + * {@link PageObject} implementation for GWT text boxes. + */ +public class TextBoxPO extends TextBoxBasePO { + + private static final String TAG_NAME = "input"; + private static final String CSS_CLASS = "gwt-TextBox"; + + /** + * Factory method to create a {@link TextBoxPO}. + * + * @param driver the web driver to use + * @param element the element representing the text box on the page + * @return a new {@link TextBoxPO} instance + */ + public static TextBoxPO create(WebDriver driver, WebElement element) { + return new TextBoxPO(driver, element); + } + + /** + * @see TextBoxBasePO#TextBoxBasePO(WebDriver, WebElement) + */ + protected TextBoxPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + @Override + protected String getTagName() { + return TAG_NAME; + } + + @Override + protected String getCssClassName() { + return CSS_CLASS; + } + +} From 0dcb373ac263f9fa644359e43f9d098989ac28af Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 13:48:49 +0100 Subject: [PATCH 017/178] Adjusted pages object for event creation dialog to use new input POs --- .../event/EventCreateDialogPO.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java index 15fa7a9b574..da52c31ab09 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java @@ -10,11 +10,14 @@ import org.openqa.selenium.WebElement; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.pages.common.DataEntryDialogPO; +import com.sap.sailing.selenium.pages.gwt.BetterDateTimeBoxPO; import com.sap.sailing.selenium.pages.gwt.CheckBoxPO; +import com.sap.sailing.selenium.pages.gwt.TextAreaPO; +import com.sap.sailing.selenium.pages.gwt.TextBoxPO; public class EventCreateDialogPO extends DataEntryDialogPO { - private static final DateFormat DATE_TIME_BOX_FORMAT = new SimpleDateFormat("dd/mm/yyyy hh:mm"); + private static final DateFormat DATE_TIME_BOX_FORMAT = new SimpleDateFormat("dd/MM/yyyy hh:mm"); @FindBy(how = BySeleniumId.class, using = "NameTextBox") private WebElement nameTextBox; @@ -39,19 +42,13 @@ public class EventCreateDialogPO extends DataEntryDialogPO { } void createEvent(String name, String description, String venue, Date start, Date end, boolean isPublic) { - setTextValue(nameTextBox, name); - setTextValue(descriptionTextArea, description); - setTextValue(venueTextBox, venue); - setTextValue(startDateTimeBox, DATE_TIME_BOX_FORMAT.format(start)); - setTextValue(endDateTimeBox, DATE_TIME_BOX_FORMAT.format(end)); - CheckBoxPO checkBox = new CheckBoxPO(driver, isPublicCheckBox); - checkBox.setSelected(isPublic); + TextBoxPO.create(driver, nameTextBox).appendText(name); + TextAreaPO.create(driver, descriptionTextArea).appendText(description); + TextBoxPO.create(driver, venueTextBox).appendText(venue); + BetterDateTimeBoxPO.create(driver, startDateTimeBox).setText(DATE_TIME_BOX_FORMAT.format(start)); + BetterDateTimeBoxPO.create(driver, endDateTimeBox).setText(DATE_TIME_BOX_FORMAT.format(end)); + CheckBoxPO.create(driver, isPublicCheckBox).setSelected(isPublic); pressOk(); } - - private void setTextValue(WebElement webElement, String value) { - webElement.clear(); - webElement.sendKeys(value); - } } From 5f7749f95eb0c19b761ae5a434aab396c913231a Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 13:54:38 +0100 Subject: [PATCH 018/178] Added documentation to BetterDateTimeBoxPO --- .../com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java index 93abfa5462c..ea380d4d316 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java @@ -31,6 +31,8 @@ public class BetterDateTimeBoxPO extends TextBoxPO { @Override public void appendText(String text) { super.appendText(text); + // Send tabulator key after changing text to ensure the date time boxes datepicker popup is closed. + // Otherwise, the popup potentially overlaps other controls, which can cause unexpected errors. super.appendText("\t"); } From 633ca7d803fb51ad15f01633a9a5ebffc2c33dcd Mon Sep 17 00:00:00 2001 From: fmittag Date: Thu, 10 Mar 2016 15:54:48 +0100 Subject: [PATCH 019/178] basic bundles and draft version of yachtscoring result importer (XRR) --- java/com.sap.sailing.feature/feature.xml | 7 + .../.classpath | 8 + .../.gitignore | 2 + .../.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 12 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 21 + .../build.properties | 5 + .../pom.xml | 12 + .../event1390_KeyWestRaceWeek2016_xrr.xml | 1754 +++++++++++++++++ .../resources/eventResults.json | 1 + .../test/EventResultJsonServiceTest.java | 39 + .../resultimport/test/ParserTest.java | 118 ++ .../resultimport/test/PersistenceTest.java | 48 + .../.classpath | 7 + .../.gitignore | 1 + .../.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 12 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 17 + .../build.properties | 4 + .../pom.xml | 12 + .../yachtscoring/resultimport/Activator.java | 35 + .../ScoreCorrectionProviderImpl.java | 143 ++ .../YachtscoringResultDocumentProvider.java | 59 + java/com.sap.sailing.yachtscoring/.classpath | 7 + java/com.sap.sailing.yachtscoring/.gitignore | 3 + java/com.sap.sailing.yachtscoring/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 12 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 13 + .../build.properties | 5 + java/com.sap.sailing.yachtscoring/pom.xml | 12 + .../yachtscoring/EventResultDescriptor.java | 81 + .../yachtscoring/RaceResultDescriptor.java | 80 + .../yachtscoring/RegattaResultDescriptor.java | 118 ++ .../YachtscoringEventResultsParser.java | 8 + .../YachtscoringEventResultsParserImpl.java | 151 ++ java/pom.xml | 1049 +++++----- 39 files changed, 3426 insertions(+), 523 deletions(-) create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/.classpath create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/.gitignore create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/.project create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.jdt.core.prefs create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.pde.core.prefs create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/META-INF/MANIFEST.MF create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/build.properties create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/pom.xml create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/resources/eventResults.json create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/EventResultJsonServiceTest.java create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/PersistenceTest.java create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/.classpath create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/.gitignore create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/.project create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.jdt.core.prefs create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.pde.core.prefs create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/META-INF/MANIFEST.MF create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/build.properties create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/pom.xml create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/Activator.java create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java create mode 100644 java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java create mode 100644 java/com.sap.sailing.yachtscoring/.classpath create mode 100644 java/com.sap.sailing.yachtscoring/.gitignore create mode 100644 java/com.sap.sailing.yachtscoring/.project create mode 100644 java/com.sap.sailing.yachtscoring/.settings/org.eclipse.jdt.core.prefs create mode 100644 java/com.sap.sailing.yachtscoring/.settings/org.eclipse.pde.core.prefs create mode 100644 java/com.sap.sailing.yachtscoring/META-INF/MANIFEST.MF create mode 100644 java/com.sap.sailing.yachtscoring/build.properties create mode 100644 java/com.sap.sailing.yachtscoring/pom.xml create mode 100644 java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/EventResultDescriptor.java create mode 100644 java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RaceResultDescriptor.java create mode 100644 java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RegattaResultDescriptor.java create mode 100644 java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParser.java create mode 100644 java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParserImpl.java diff --git a/java/com.sap.sailing.feature/feature.xml b/java/com.sap.sailing.feature/feature.xml index dd6184140a1..12e6cbee047 100755 --- a/java/com.sap.sailing.feature/feature.xml +++ b/java/com.sap.sailing.feature/feature.xml @@ -247,6 +247,13 @@ Computes leaderboard information for sailing races and offers RESTful APIs to al version="0.0.0" unpack="false"/> + + + + + + + + + diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/.gitignore b/java/com.sap.sailing.yachtscoring.resultimport.test/.gitignore new file mode 100644 index 00000000000..4431bb9d346 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/.gitignore @@ -0,0 +1,2 @@ +bin/ +/bin diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/.project b/java/com.sap.sailing.yachtscoring.resultimport.test/.project new file mode 100644 index 00000000000..a82f819be56 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/.project @@ -0,0 +1,28 @@ + + + com.sap.sailing.yachtscoring.resultimport.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.jdt.core.prefs b/java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..ace45ceefb4 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.pde.core.prefs b/java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000000..b7e72d019c2 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/META-INF/MANIFEST.MF b/java/com.sap.sailing.yachtscoring.resultimport.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..d3021c8f440 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Yachtscoring result import tests +Bundle-SymbolicName: com.sap.sailing.yachtscoring.resultimport.test +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: SAP +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: com.sap.sailing.domain.common, + com.sap.sailing.domain.leaderboard, + com.sap.sailing.domain.persistence, + com.sap.sailing.server, + com.sap.sailing.server.impl, + com.sap.sailing.xrr.schema, + org.osgi.framework;version="1.5.0" +Fragment-Host: com.sap.sailing.yachtscoring.resultimport +Require-Bundle: org.junit4;bundle-version="4.8.2", + com.sap.sse.common, + org.mockito.mockito-core;bundle-version="1.9.5", + org.objenesis;bundle-version="1.3.0", + org.hamcrest;bundle-version="1.1.0", + com.sap.sse diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/build.properties b/java/com.sap.sailing.yachtscoring.resultimport.test/build.properties new file mode 100644 index 00000000000..a2e16dfebcd --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/,\ + resources/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/pom.xml b/java/com.sap.sailing.yachtscoring.resultimport.test/pom.xml new file mode 100644 index 00000000000..2a494762480 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + root + com.sap.sailing + 1.0.0-SNAPSHOT + + com.sap.sailing.yachtscoring.resultimport.test + eclipse-test-plugin + diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml new file mode 100644 index 00000000000..c51883d4705 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml @@ -0,0 +1,1754 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/eventResults.json b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/eventResults.json new file mode 100644 index 00000000000..9e26dfeeb6e --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/eventResults.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/EventResultJsonServiceTest.java b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/EventResultJsonServiceTest.java new file mode 100644 index 00000000000..c3c625a3556 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/EventResultJsonServiceTest.java @@ -0,0 +1,39 @@ +package com.sap.sailing.yachtscoring.resultimport.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Test; + +import com.sap.sailing.yachtscoring.EventResultDescriptor; +import com.sap.sailing.yachtscoring.YachtscoringEventResultsParserImpl; + +public class EventResultJsonServiceTest { + private static final String EVENT_RESULTS_JSON = "eventResults.json"; + + private static final String RESOURCES = "resources/"; + + @Test + public void testParsingEventResultsFromJson() throws IOException { + YachtscoringEventResultsParserImpl parser = new YachtscoringEventResultsParserImpl(); + + EventResultDescriptor eventResult = parser.getEventResult(getInputStream(EVENT_RESULTS_JSON)); + assertNotNull(eventResult); + + assertEquals(14, eventResult.getRegattaResults().size()); + } + + private InputStream getInputStream(String filename) throws FileNotFoundException, IOException { + return new FileInputStream(getFile(filename)); + } + + private File getFile(String filename) { + return new File(RESOURCES + filename); + } +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java new file mode 100644 index 00000000000..5eaa0a4c555 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java @@ -0,0 +1,118 @@ +package com.sap.sailing.yachtscoring.resultimport.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.DatatypeConverter; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import org.junit.Test; +import org.xml.sax.SAXException; + +import com.sap.sailing.domain.persistence.DomainObjectFactory; +import com.sap.sailing.domain.persistence.MongoObjectFactory; +import com.sap.sailing.resultimport.ResultDocumentDescriptor; +import com.sap.sailing.resultimport.ResultDocumentProvider; +import com.sap.sailing.resultimport.ResultUrlRegistry; +import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl; +import com.sap.sailing.resultimport.impl.ResultUrlRegistryImpl; +import com.sap.sailing.xrr.resultimport.ParserFactory; +import com.sap.sailing.xrr.schema.RegattaResults; +import com.sap.sailing.yachtscoring.resultimport.ScoreCorrectionProviderImpl; +import com.sap.sse.common.TimePoint; +import com.sap.sse.common.impl.MillisecondsTimePoint; + +public class ParserTest { + private static final String SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK = "event1390_KeyWestRaceWeek2016_xrr.xml"; + private static final String KEYWESTRACEWEEEK_EVENT_NAME = "Key West Race Week 2016"; + private static final String ISAF_ID_29ER = "29ER"; + + private static final String RESOURCES = "resources/"; + + private InputStream getInputStream(String filename) throws FileNotFoundException, IOException { + return new FileInputStream(getFile(filename)); + } + + private File getFile(String filename) { + return new File(RESOURCES + filename); + } + + private ResultDocumentProvider getTestDocumentProvider() { + return new ResultDocumentProvider() { + @Override + public Iterable getResultDocumentDescriptors() throws IOException { + try { + List result = new ArrayList(); + + Date _29erDate = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); + result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK), + null, new MillisecondsTimePoint(_29erDate), KEYWESTRACEWEEEK_EVENT_NAME , null, ISAF_ID_29ER)); + + return result; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + } + + @Test + public void testSimpleParsingSomeYachtscoringDocuments() throws JAXBException, IOException { + RegattaResults r1 = ParserFactory.INSTANCE.createParser(getInputStream(SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK), KEYWESTRACEWEEEK_EVENT_NAME).parse(); + assertNotNull(r1); + + } + + @Test + public void testScoreCorrectionProviderFeedingAndHasResults() throws IOException, SAXException, + ParserConfigurationException, JAXBException { + ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mock(MongoObjectFactory.class), + mock(DomainObjectFactory.class)); + ScoreCorrectionProviderImpl scoreCorrectionProvider = new ScoreCorrectionProviderImpl( + getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); + Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); + + Set> resultsForYES = hasResultsFor.get(KEYWESTRACEWEEEK_EVENT_NAME); + assertNotNull(resultsForYES); + + assertEquals(3, resultsForYES.size()); + } + +// @Test +// public void testScoreCorrectionProvider() throws Exception { +// ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mock(MongoObjectFactory.class), +// mock(DomainObjectFactory.class)); +// ScoreCorrectionProviderImpl scoreCorrectionProvider = new ScoreCorrectionProviderImpl( +// getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); +// Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); +// Set> resultsForYES = hasResultsFor.get(YES_EVENT_NAME); +// com.sap.sse.common.Util.Pair resultFor29er = null; +// for(com.sap.sse.common.Util.Pair result: resultsForYES) { +// if(result.getA().equals(ISAF_ID_29ER)) { +// resultFor29er = result; +// break; +// } +// } +// assertNotNull(resultFor29er); +// +// RegattaScoreCorrections _29erResult = scoreCorrectionProvider.getScoreCorrections(YES_EVENT_NAME, ISAF_ID_29ER , resultFor29er.getB()); +// assertNotNull(_29erResult); +// Iterable scoreCorrectionsForRaces = _29erResult.getScoreCorrectionsForRaces(); +// assertNotNull(scoreCorrectionsForRaces); +// assertEquals(8, Util.size(scoreCorrectionsForRaces)); +// } + +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/PersistenceTest.java b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/PersistenceTest.java new file mode 100644 index 00000000000..f398129afd5 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/PersistenceTest.java @@ -0,0 +1,48 @@ +package com.sap.sailing.yachtscoring.resultimport.test; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; +import java.util.Set; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.sap.sailing.domain.persistence.DomainObjectFactory; +import com.sap.sailing.domain.persistence.MongoObjectFactory; +import com.sap.sailing.resultimport.ResultUrlRegistry; +import com.sap.sailing.resultimport.impl.ResultUrlRegistryImpl; +import com.sap.sailing.server.RacingEventService; +import com.sap.sailing.server.impl.RacingEventServiceImpl; + +@SuppressWarnings("restriction") +public class PersistenceTest { + + @Test + public void testResultUrlStoring() throws MalformedURLException { + RacingEventService racingEventService = new RacingEventServiceImpl(); + DomainObjectFactory domainObjectFactory = racingEventService.getDomainObjectFactory(); + MongoObjectFactory mongoObjectFactory = racingEventService.getMongoObjectFactory(); + + ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mongoObjectFactory, domainObjectFactory); + + String testProviderName = "TestProvider"; + URL testUrl = new URL("http://www.yachtscoring.com/results_xrr.cfm?Spec_Race=6&eid=1220"); + resultUrlRegistry.registerResultUrl(testProviderName, testUrl); + + Map> resultUrls = domainObjectFactory.loadResultUrls(); + Assert.assertTrue(resultUrls.containsKey(testProviderName)); + Set urls = resultUrls.get(testProviderName); + Assert.assertEquals(1, urls.size()); + URL url = urls.iterator().next(); + Assert.assertEquals(testUrl, url); + + resultUrlRegistry.unregisterResultUrl(testProviderName, testUrl); + + resultUrls = domainObjectFactory.loadResultUrls(); + Assert.assertFalse(resultUrls.containsKey(testProviderName)); + + } + +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport/.classpath b/java/com.sap.sailing.yachtscoring.resultimport/.classpath new file mode 100644 index 00000000000..b862a296d38 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/java/com.sap.sailing.yachtscoring.resultimport/.gitignore b/java/com.sap.sailing.yachtscoring.resultimport/.gitignore new file mode 100644 index 00000000000..44519b5db33 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/java/com.sap.sailing.yachtscoring.resultimport/.project b/java/com.sap.sailing.yachtscoring.resultimport/.project new file mode 100644 index 00000000000..ecfabb911f1 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/.project @@ -0,0 +1,28 @@ + + + com.sap.sailing.yachtscoring.resultimport + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.jdt.core.prefs b/java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..ace45ceefb4 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.pde.core.prefs b/java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000000..b7e72d019c2 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/java/com.sap.sailing.yachtscoring.resultimport/META-INF/MANIFEST.MF b/java/com.sap.sailing.yachtscoring.resultimport/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..fe22c8eadc1 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Yachtscoring Result import +Bundle-SymbolicName: com.sap.sailing.yachtscoring.resultimport +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: com.sap.sailing.yachtscoring.resultimport.Activator +Bundle-Vendor: SAP +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.osgi.framework;version="1.5.0", + org.osgi.util.tracker;version="1.5.1" +Bundle-ActivationPolicy: lazy +Require-Bundle: com.sap.sailing.yachtscoring, + com.sap.sailing.domain.common, + com.sap.sailing.resultimport, + com.sap.sailing.xrr.resultimport, + com.sap.sse.common, + com.sap.sailing.xrr.schema diff --git a/java/com.sap.sailing.yachtscoring.resultimport/build.properties b/java/com.sap.sailing.yachtscoring.resultimport/build.properties new file mode 100644 index 00000000000..41eb6ade2b4 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/java/com.sap.sailing.yachtscoring.resultimport/pom.xml b/java/com.sap.sailing.yachtscoring.resultimport/pom.xml new file mode 100644 index 00000000000..8fd6652067b --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + root + com.sap.sailing + 1.0.0-SNAPSHOT + + com.sap.sailing.yachtscoring.resultimport + eclipse-plugin + diff --git a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/Activator.java b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/Activator.java new file mode 100644 index 00000000000..1d290905c33 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/Activator.java @@ -0,0 +1,35 @@ +package com.sap.sailing.yachtscoring.resultimport; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.util.tracker.ServiceTracker; + +import com.sap.sailing.domain.common.ScoreCorrectionProvider; +import com.sap.sailing.resultimport.ResultUrlRegistry; +import com.sap.sailing.resultimport.impl.ResultUrlRegistryServiceTrackerCustomizer; +import com.sap.sailing.xrr.resultimport.ParserFactory; + +public class Activator implements BundleActivator { + + private ServiceTracker resultUrlRegistryServiceTracker; + + public void start(BundleContext bundleContext) throws Exception { + resultUrlRegistryServiceTracker = new ServiceTracker<>(bundleContext, ResultUrlRegistry.class, + new ResultUrlRegistryServiceTrackerCustomizer(bundleContext) { + + @Override + protected ScoreCorrectionProvider configureScoreCorrectionProvider( + ResultUrlRegistry resultUrlRegistry) { + final ScoreCorrectionProviderImpl service = new ScoreCorrectionProviderImpl( + ParserFactory.INSTANCE, resultUrlRegistry); + return service; + } + }); + + resultUrlRegistryServiceTracker.open(); + } + + public void stop(BundleContext bundleContext) throws Exception { + resultUrlRegistryServiceTracker.close(); + } +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java new file mode 100644 index 00000000000..0759eadcca1 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java @@ -0,0 +1,143 @@ +package com.sap.sailing.yachtscoring.resultimport; + +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.logging.Logger; + +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; + +import com.sap.sailing.domain.common.RegattaScoreCorrections; +import com.sap.sailing.domain.common.ScoreCorrectionProvider; +import com.sap.sailing.resultimport.ResultDocumentDescriptor; +import com.sap.sailing.resultimport.ResultDocumentProvider; +import com.sap.sailing.resultimport.ResultUrlProvider; +import com.sap.sailing.resultimport.ResultUrlRegistry; +import com.sap.sailing.xrr.resultimport.Parser; +import com.sap.sailing.xrr.resultimport.ParserFactory; +import com.sap.sailing.xrr.resultimport.impl.XRRRegattaResultsAsScoreCorrections; +import com.sap.sailing.xrr.schema.Division; +import com.sap.sailing.xrr.schema.Event; +import com.sap.sailing.xrr.schema.EventGender; +import com.sap.sailing.xrr.schema.RegattaResults; +import com.sap.sse.common.TimePoint; +import com.sap.sse.common.Util; + +public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, ResultUrlProvider { + private static final Logger logger = Logger.getLogger(ScoreCorrectionProviderImpl.class.getName()); + private static final long serialVersionUID = 222663322974305822L; + + public static final String NAME = "Yachtscoring XRR Result Importer"; + + private final ParserFactory parserFactory; + private final ResultUrlRegistry resultUrlRegistry; + private final ResultDocumentProvider documentProvider; + + public ScoreCorrectionProviderImpl(ResultDocumentProvider documentProvider, ParserFactory parserFactory, ResultUrlRegistry resultUrlRegistry) { + this.documentProvider = documentProvider; + this.parserFactory = parserFactory; + this.resultUrlRegistry = resultUrlRegistry; + } + + public ScoreCorrectionProviderImpl(ParserFactory parserFactory, ResultUrlRegistry resultUrlRegistry) { + this.documentProvider = new YachtscoringResultDocumentProvider(this); + this.parserFactory = parserFactory; + this.resultUrlRegistry = resultUrlRegistry; + } + + @Override + public String getName() { + return NAME; + } + + @Override + public Map>> getHasResultsForBoatClassFromDateByEventName() { + Map>> result = new HashMap>>(); + try { + for (ResultDocumentDescriptor resultDocDescr : documentProvider.getResultDocumentDescriptors()) { + String eventName = resultDocDescr.getEventName() != null ? resultDocDescr.getEventName() : resultDocDescr.getRegattaName(); + String boatClass = resultDocDescr.getBoatClass(); + if(boatClass != null && eventName != null) { + if(resultDocDescr.getCompetitorGenderType() != null) { + boatClass += ", " + resultDocDescr.getCompetitorGenderType().name(); + } + Set> eventResultsSet = result.get(eventName); + if(eventResultsSet == null) { + eventResultsSet = new HashSet>(); + result.put(eventName, eventResultsSet); + } + eventResultsSet.add(new Util.Pair(boatClass, resultDocDescr.getLastModified())); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public RegattaScoreCorrections getScoreCorrections(String eventName, String boatClassName, + TimePoint timePointPublished) throws IOException, SAXException, ParserConfigurationException { + Parser parser = resolveParser(eventName, boatClassName); + try { + RegattaResults regattaResults = parser.parse(); + for (Object o : regattaResults.getPersonOrBoatOrTeam()) { + if (o instanceof Event) { + Event event = (Event) o; + if (event.getTitle().equals(eventName)) { + for (Object eventO : event.getRaceOrDivisionOrRegattaSeriesResult()) { + if (eventO instanceof Division) { + Division division = (Division) eventO; + EventGender divisionGender = division.getGender(); + String divisionBoatClassAndGender = parser.getBoatClassName(division); + if(divisionGender != null) { + divisionBoatClassAndGender += ", " + divisionGender.name(); + } + if (boatClassName.equalsIgnoreCase(divisionBoatClassAndGender) || boatClassName.contains(divisionBoatClassAndGender)) { + return new XRRRegattaResultsAsScoreCorrections(event, division, this, + parser); + } + } + } + } + } +// } + } + } catch (JAXBException e) { + logger.info("Parse error during XRR import. Ignoring document " + parser.toString()); + logger.throwing(ScoreCorrectionProviderImpl.class.getName(), "getHasResultsForBoatClassFromDateByEventName", e); + } + return null; + } + + private Parser resolveParser(String eventName, String boatClassName) throws IOException { + Parser result = null; + for (ResultDocumentDescriptor resultDocDescr : documentProvider.getResultDocumentDescriptors()) { + String boatClassAndGenderType = resultDocDescr.getBoatClass(); + if(resultDocDescr.getCompetitorGenderType() != null) { + boatClassAndGenderType += ", " + resultDocDescr.getCompetitorGenderType().name(); + } + if(eventName.equals(resultDocDescr.getEventName()) && boatClassName.equals(boatClassAndGenderType)) { + result = parserFactory.createParser(resultDocDescr.getInputStream(), resultDocDescr.getEventName()); + break; + } + } + return result; + } + + @Override + public Iterable getUrls() { + return resultUrlRegistry.getResultUrls(NAME); + } + + @Override + public String getOptionalSampleURL() { + return "http://www.yachtscoring.com/results_xrr.cfm?Spec_Race=6&eid=1220"; + } +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java new file mode 100644 index 00000000000..de650cd9a18 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java @@ -0,0 +1,59 @@ +package com.sap.sailing.yachtscoring.resultimport; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +import com.sap.sailing.yachtscoring.EventResultDescriptor; +import com.sap.sailing.yachtscoring.YachtscoringEventResultsParserImpl; +import com.sap.sailing.yachtscoring.RegattaResultDescriptor; +import com.sap.sailing.resultimport.ResultDocumentDescriptor; +import com.sap.sailing.resultimport.ResultDocumentProvider; +import com.sap.sailing.resultimport.ResultUrlProvider; +import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl; +import com.sap.sse.common.impl.MillisecondsTimePoint; + +public class YachtscoringResultDocumentProvider implements ResultDocumentProvider { + private final ResultUrlProvider resultUrlProvider; + + public YachtscoringResultDocumentProvider(final ResultUrlProvider resultUrlProvider) { + this.resultUrlProvider = resultUrlProvider; + } + + @Override + public Iterable getResultDocumentDescriptors() throws IOException { + List result = new ArrayList<>(); + YachtscoringEventResultsParserImpl parser = new YachtscoringEventResultsParserImpl(); + for (URL url : resultUrlProvider.getUrls()) { + URLConnection eventResultConn = url.openConnection(); + EventResultDescriptor eventResult = parser.getEventResult((InputStream) eventResultConn.getContent()); + if (eventResult != null) { + for (RegattaResultDescriptor regattaResult : eventResult.getRegattaResults()) { + // Depending on the regatta type the boat class in the XRR is set or not (in the division tag) + // Olympic boat classes -> IFClassID="2.4M" Title="2.4M open" + // International boat classes -> IFClassID="" Title="Coachboat" + // Open boat classes (ORC) -> IFClassID="" Title="Welcome Race ORC-Club" + // -> therefore we need to take the regatta title as boat class where the IsafID is not available + String boatClass = regattaResult.getIsafId() != null && !regattaResult.getIsafId().isEmpty() ? regattaResult.getIsafId() : regattaResult.getName(); + if (regattaResult.getIsFinal() != null && regattaResult.getPublishedAt() != null) { + if (regattaResult.getIsFinal() && regattaResult.getXrrFinalUrl() != null) { + URLConnection regattaResultConn = regattaResult.getXrrFinalUrl().openConnection(); + result.add(new ResultDocumentDescriptorImpl((InputStream) regattaResultConn.getContent(), + regattaResult.getXrrPreliminaryUrl().toString(), new MillisecondsTimePoint(regattaResult.getPublishedAt()), + eventResult.getName(), regattaResult.getName(), boatClass, regattaResult.getCompetitorGenderType())); + } else if (regattaResult.getXrrPreliminaryUrl() != null) { + URLConnection regattaResultConn = regattaResult.getXrrPreliminaryUrl().openConnection(); + result.add(new ResultDocumentDescriptorImpl((InputStream) regattaResultConn.getContent(), + regattaResult.getXrrPreliminaryUrl().toString(), new MillisecondsTimePoint(regattaResult.getPublishedAt()), + eventResult.getName(), regattaResult.getName(), boatClass, regattaResult.getCompetitorGenderType())); + } + } + } + } + } + return result; + } +} diff --git a/java/com.sap.sailing.yachtscoring/.classpath b/java/com.sap.sailing.yachtscoring/.classpath new file mode 100644 index 00000000000..b862a296d38 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/java/com.sap.sailing.yachtscoring/.gitignore b/java/com.sap.sailing.yachtscoring/.gitignore new file mode 100644 index 00000000000..5246d45ff87 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/.gitignore @@ -0,0 +1,3 @@ +bin/ +/bin/ +/bin/ diff --git a/java/com.sap.sailing.yachtscoring/.project b/java/com.sap.sailing.yachtscoring/.project new file mode 100644 index 00000000000..329124b8fd8 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/.project @@ -0,0 +1,28 @@ + + + com.sap.sailing.yachtscoring + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/java/com.sap.sailing.yachtscoring/.settings/org.eclipse.jdt.core.prefs b/java/com.sap.sailing.yachtscoring/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..ace45ceefb4 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/java/com.sap.sailing.yachtscoring/.settings/org.eclipse.pde.core.prefs b/java/com.sap.sailing.yachtscoring/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000000..b7e72d019c2 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/java/com.sap.sailing.yachtscoring/META-INF/MANIFEST.MF b/java/com.sap.sailing.yachtscoring/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..59b615fa292 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Yachtscoring +Bundle-SymbolicName: com.sap.sailing.yachtscoring +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: SAP +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Require-Bundle: org.json.simple;bundle-version="1.1.0", + com.sap.sailing.domain.common, + com.sap.sailing.domain, + com.sap.sse +Export-Package: com.sap.sailing.yachtscoring diff --git a/java/com.sap.sailing.yachtscoring/build.properties b/java/com.sap.sailing.yachtscoring/build.properties new file mode 100644 index 00000000000..a2e16dfebcd --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/build.properties @@ -0,0 +1,5 @@ +source.. = src/,\ + resources/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/java/com.sap.sailing.yachtscoring/pom.xml b/java/com.sap.sailing.yachtscoring/pom.xml new file mode 100644 index 00000000000..806c24c47f5 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + root + com.sap.sailing + 1.0.0-SNAPSHOT + + com.sap.sailing.yachtscoring + eclipse-plugin + diff --git a/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/EventResultDescriptor.java b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/EventResultDescriptor.java new file mode 100644 index 00000000000..4056476c727 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/EventResultDescriptor.java @@ -0,0 +1,81 @@ +package com.sap.sailing.yachtscoring; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * Reads the list of regattas for an event with a given yachtscoring event id + * @author Frank + * + */ +public class EventResultDescriptor { + private List regattaResults; + private String id; + private String isafId; + private String name; + private URL xrrUrl; + + private String trackingDataHost; + private Integer trackingDataPort; + + public EventResultDescriptor() { + regattaResults = new ArrayList(); + } + + public List getRegattaResults() { + return regattaResults; + } + + public void setRegattaResults(List regattaResults) { + this.regattaResults = regattaResults; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public URL getXrrUrl() { + return xrrUrl; + } + + public void setXrrUrl(URL xrrUrl) { + this.xrrUrl = xrrUrl; + } + + public String getIsafId() { + return isafId; + } + + public void setIsafId(String isafId) { + this.isafId = isafId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTrackingDataHost() { + return trackingDataHost; + } + + public void setTrackingDataHost(String trackingDataHost) { + this.trackingDataHost = trackingDataHost; + } + + public Integer getTrackingDataPort() { + return trackingDataPort; + } + + public void setTrackingDataPort(Integer trackingDataPort) { + this.trackingDataPort = trackingDataPort; + } +} diff --git a/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RaceResultDescriptor.java b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RaceResultDescriptor.java new file mode 100644 index 00000000000..498497f00d0 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RaceResultDescriptor.java @@ -0,0 +1,80 @@ +package com.sap.sailing.yachtscoring; + +import java.util.Date; + +public class RaceResultDescriptor { + private String id; + private String name; + private Integer raceColumnNumber; + private String seriesName; + private String fleetName; + private Boolean isTracked; + private Date startTime; + + /** Possible states: Scheduled, StartSequence, Racing, Finished, GeneralRecall, Postponed, Abandoned */ + private String status; + + public Integer getRaceColumnNumber() { + return raceColumnNumber; + } + + public void setRaceColumnNumber(Integer raceColumnNumber) { + this.raceColumnNumber = raceColumnNumber; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getSeriesName() { + return seriesName; + } + + public void setSeriesName(String seriesName) { + this.seriesName = seriesName; + } + + public String getFleetName() { + return fleetName; + } + + public void setFleetName(String fleetName) { + this.fleetName = fleetName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean isTracked() { + return isTracked; + } + + public void setTracked(Boolean isTracked) { + this.isTracked = isTracked; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } +} diff --git a/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RegattaResultDescriptor.java b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RegattaResultDescriptor.java new file mode 100644 index 00000000000..792f2ed46db --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/RegattaResultDescriptor.java @@ -0,0 +1,118 @@ +package com.sap.sailing.yachtscoring; + +import java.net.URL; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.sap.sailing.domain.common.CompetitorGenderType; + +public class RegattaResultDescriptor { + private String id; + private String isafId; + private String externalId; + private String name; + private String className; + private CompetitorGenderType competitorGenderType; + private URL pdfUrl; + private URL xrrPreliminaryUrl; + private URL xrrFinalUrl; + private URL xrrEntriesUrl; + private URL htmlUrl; + private Date publishedAt; + private Boolean isFinal; + private List raceResults; + + public RegattaResultDescriptor() { + raceResults = new ArrayList(); + } + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getIsafId() { + return isafId; + } + public void setIsafId(String isafId) { + this.isafId = isafId; + } + public String getExternalId() { + return externalId; + } + public void setExternalId(String externalId) { + this.externalId = externalId; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getClassName() { + return className; + } + public void setClassName(String className) { + this.className = className; + } + public URL getPdfUrl() { + return pdfUrl; + } + public void setPdfUrl(URL pdfUrl) { + this.pdfUrl = pdfUrl; + } + public URL getXrrPreliminaryUrl() { + return xrrPreliminaryUrl; + } + public void setXrrPreliminaryUrl(URL xrrPreliminaryUrl) { + this.xrrPreliminaryUrl = xrrPreliminaryUrl; + } + public URL getXrrFinalUrl() { + return xrrFinalUrl; + } + public void setXrrFinalUrl(URL xrrFinalUrl) { + this.xrrFinalUrl = xrrFinalUrl; + } + public URL getHtmlUrl() { + return htmlUrl; + } + public void setHtmlUrl(URL htmlUrl) { + this.htmlUrl = htmlUrl; + } + public Date getPublishedAt() { + return publishedAt; + } + public void setPublishedAt(Date publishedAt) { + this.publishedAt = publishedAt; + } + public Boolean getIsFinal() { + return isFinal; + } + public void setIsFinal(Boolean isFinal) { + this.isFinal = isFinal; + } + public CompetitorGenderType getCompetitorGenderType() { + return competitorGenderType; + } + public void setCompetitorGenderType(CompetitorGenderType competitorGenderType) { + this.competitorGenderType = competitorGenderType; + } + + public List getRaceResults() { + return raceResults; + } + + public void setRaceResults(List raceResults) { + this.raceResults = raceResults; + } + + public URL getXrrEntriesUrl() { + return xrrEntriesUrl; + } + + public void setXrrEntriesUrl(URL xrrEntriesUrl) { + this.xrrEntriesUrl = xrrEntriesUrl; + } +} diff --git a/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParser.java b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParser.java new file mode 100644 index 00000000000..db5307eff8d --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParser.java @@ -0,0 +1,8 @@ +package com.sap.sailing.yachtscoring; + +import java.io.IOException; +import java.io.InputStream; + +public interface YachtscoringEventResultsParser { + public EventResultDescriptor getEventResult(InputStream is) throws IOException; +} diff --git a/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParserImpl.java b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParserImpl.java new file mode 100644 index 00000000000..51772dc9a53 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring/src/com/sap/sailing/yachtscoring/YachtscoringEventResultsParserImpl.java @@ -0,0 +1,151 @@ +package com.sap.sailing.yachtscoring; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Date; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import com.sap.sailing.domain.common.CompetitorGenderType; +import com.sap.sse.InvalidDateException; +import com.sap.sse.util.DateParser; + +/** + * URLs should be of the form + *
+ * http://www.yachtscoring.com/results_xrr.cfm?Spec_Race=6&eid=1390
+ * 
+ * where eid the event ID. Events can be discovered by the yachtscoring.com website. + * + * @author Frank Mittag (C5163874) + * + */ +public class YachtscoringEventResultsParserImpl implements YachtscoringEventResultsParser { + + /** + * @param is closed before the method returns, also in case of exception + * @throws IOException + */ + public EventResultDescriptor getEventResult(InputStream is) throws IOException { + EventResultDescriptor result = null; + try { + JSONObject jsonRoot = (JSONObject) new JSONParser().parse(new InputStreamReader(is, "UTF-8")); + result = new EventResultDescriptor(); + result.setId((String) jsonRoot.get("Id")); + result.setIsafId((String) jsonRoot.get("IsafId")); + result.setName((String) jsonRoot.get("Name")); + result.setXrrUrl(parseURL(jsonRoot, "XrrUrl")); + JSONObject jsonTracking = (JSONObject) jsonRoot.get("Tracking"); + if (jsonTracking != null) { + result.setTrackingDataHost((String) jsonTracking.get("Host")); + result.setTrackingDataPort(parseInteger(jsonTracking, "Port")); + } + + JSONArray jsonRegattas = (JSONArray) jsonRoot.get("Regattas"); + for (Object regattaObject: jsonRegattas) { + RegattaResultDescriptor regattaResult = new RegattaResultDescriptor(); + JSONObject jsonRegatta = (JSONObject) regattaObject; + regattaResult.setId((String) jsonRegatta.get("Id")); + regattaResult.setIsafId((String) jsonRegatta.get("IsafId")); + regattaResult.setExternalId((String) jsonRegatta.get("ExternalId")); + regattaResult.setName((String) jsonRegatta.get("Name")); + regattaResult.setCompetitorGenderType(parseCompetitorGenderType(jsonRegatta, "Gender")); + regattaResult.setClassName((String) jsonRegatta.get("ClassName")); + regattaResult.setPdfUrl(parseURL(jsonRegatta, "PdfUrl")); + regattaResult.setXrrPreliminaryUrl(parseURL(jsonRegatta, "XrrPreliminaryUrl")); + regattaResult.setXrrFinalUrl(parseURL(jsonRegatta, "XrrFinalUrl")); + regattaResult.setXrrEntriesUrl(parseURL(jsonRegatta, "XrrEntriesUrl")); + regattaResult.setHtmlUrl(parseURL(jsonRegatta, "HtmlUrl")); + regattaResult.setPublishedAt(parseDate(jsonRegatta, "Published")); + regattaResult.setIsFinal((Boolean) jsonRegatta.get("Final")); + + JSONArray jsonRaces = (JSONArray) jsonRegatta.get("Races"); + if(jsonRaces != null) { + for (Object raceObject: jsonRaces) { + RaceResultDescriptor raceResult = new RaceResultDescriptor(); + JSONObject jsonRace = (JSONObject) raceObject; + raceResult.setId((String) jsonRace.get("Id")); + raceResult.setName((String) jsonRace.get("Name")); + raceResult.setRaceColumnNumber(parseInteger(jsonRace, "RaceIndex")); + raceResult.setStatus((String) jsonRace.get("Status")); + raceResult.setSeriesName((String) jsonRace.get("Series")); + raceResult.setFleetName((String) jsonRace.get("Fleet")); + raceResult.setTracked((Boolean) jsonRace.get("IsTracked")); + raceResult.setStartTime(parseDate(jsonRace, "StartTime")); + regattaResult.getRaceResults().add(raceResult); + } + } + result.getRegattaResults().add(regattaResult); + } + is.close(); + } catch(ParseException e) { + e.printStackTrace(); + } finally { + is.close(); + } + return result; + } + + private CompetitorGenderType parseCompetitorGenderType(JSONObject jsonDate, String attributeName) { + CompetitorGenderType result = null; + String genderTypeAsString = (String) jsonDate.get(attributeName); + if(genderTypeAsString != null) { + switch(genderTypeAsString) { + case "M" : result = CompetitorGenderType.Men; break; + case "W" : result = CompetitorGenderType.Women; break; + case "X" : result = CompetitorGenderType.Mixed; break; + case "Open" : result = CompetitorGenderType.Open; break; + } + } + return result; + } + + private Integer parseInteger(JSONObject jsonNumber, String attributeName) { + Integer result = null; + Object object = jsonNumber.get(attributeName); + if(object != null) { + if(object instanceof Number) { + result = ((Number) object).intValue(); + } else if (object instanceof String) { + String numberAsString = (String) object; + if(!numberAsString.isEmpty()) { + try { + result = Integer.parseInt(numberAsString); + } catch (NumberFormatException e) { + } + } + } + } + return result; + } + + private Date parseDate(JSONObject jsonDate, String attributeName) { + Date result = null; + String dateAsString = (String) jsonDate.get(attributeName); + if(dateAsString != null && !dateAsString.isEmpty()) { + try { + result = DateParser.parseUTC(dateAsString); + } catch (InvalidDateException e) { + } + } + return result; + } + + private URL parseURL(JSONObject jsonURL, String attributeName) { + URL result = null; + String urlAsString = (String) jsonURL.get(attributeName); + if(urlAsString != null && !urlAsString.isEmpty()) { + try { + result = new URL(urlAsString); + } catch (MalformedURLException e) { + } + } + return result; + } +} diff --git a/java/pom.xml b/java/pom.xml index ab62aa66585..c050f6e9c65 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -1,523 +1,526 @@ - - - 4.0.0 - - - workspace - com.sap.sailing - 1.0.0-SNAPSHOT - - - root - pom - - - - com.sap.sse.common - com.sap.sse.shared.android - com.sap.sse.datamining.annotations - com.sap.sse.security.common - org.json.simple - com.sap.sailing.domain.common - com.sap.sailing.domain.shared.android - com.sap.sailing.server.gateway.serialization.shared.android - - - - 0.21.0 - 2.7.0 - 2.7.0 - 2 - race-analysis-p2-remote - - - -Dfile.encoding=cp1252 -Dmongo.dbName=winddbTest -DspatialWind=true - - - -ea -Xmx1024m -XX:+UseG1GC - - - -Dtractrac.tunnel=true -Dtractrac.tunnel.host=localhost - - - -Dmongo.host=127.0.0.1 - - - -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y - - - - -Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.wdf.sap.corp -Dhttps.proxyPort=8080 - - ${project.build.directory}/surefire-reports - false - - - - - - with-not-android-relevant - - - !ldi.releaseBuild - - - - com.sap.sse - com.sap.sse.mail - com.sap.sse.mail.replication.test - com.sap.sse.mail.replication.testsupport - com.sap.sse.mongodb - com.sap.sse.gwt - com.sap.sse.gwt.adminconsole - com.sap.sse.datamining - com.sap.sse.datamining.shared - com.sap.sse.security - com.sap.sse.security.ui - com.sap.sse.security.userstore.mongodb - com.sap.sse.operationaltransformation - com.sap.sse.replication - com.sap.sse.threadmanager - com.sap.sse.filestorage - com.sap.sailing.domain - com.sap.sailing.geocoding - com.sap.sailing.datamining - com.sap.sailing.datamining.shared - com.sap.sailing.domain.persistence - com.sap.sailing.domain.deckmanadapter - com.sap.sailing.domain.tractracadapter - com.sap.sailing.domain.tractracadapter.persistence - com.sap.sailing.domain.igtimiadapter - com.sap.sailing.domain.igtimiadapter.persistence - com.sap.sailing.domain.racelogtrackingadapter - com.sap.sailing.domain.racelogtrackingadapter.testsupport - com.sap.sailing.domain.swisstimingadapter - com.sap.sailing.domain.swisstimingadapter.persistence - com.sap.sailing.domain.swisstimingreplayadapter - com.sap.sailing.news - com.sap.sailing.declination - com.sap.sailing.udpconnector - com.sap.sailing.expeditionconnector - com.sap.sailing.server - com.sap.sailing.server.gateway - com.sap.sailing.server.gateway.serialization - com.sap.sailing.www - com.sap.sailing.xmlexport - com.google.gwt.dev - com.google.gwt.osgi - com.tractrac.clientmodule - com.googlecode.java-diff-utils - com.googlecode.mgwt - com.sap.sailing.dashboards.gwt - com.sap.sailing.feature - org.moxieapps.gwt.highcharts - com.sap.sailing.resultimport - com.sap.sailing.kiworesultimport - com.sap.sailing.ess40.resultimport - com.sap.sailing.xrr.schema - com.sap.sailing.xrr.resultimport - com.sap.sailing.xrr.structureimport - com.sap.sailing.freg.resultimport - org.openqa.selenium.osgi - com.sap.sailing.monitoring - com.sap.sailing.simulator - com.sap.sailing.server.trackfiles - com.sap.sailing.feature.runtime - com.sap.sailing.gwt.ui - com.sap.sailing.domain.test - com.sap.sse.replication.testsupport - - com.sap.sse.gwt.test - - com.sap.sse.datamining.test - com.sap.sse.security.replication.test - com.sap.sse.security.test - com.sap.sse.operationaltransformation.test - com.sap.sse.common.test - com.sap.sse.filestorage.test - com.sap.sailing.datamining.test - com.sap.sailing.domain.deckmanadapter.test - com.sap.sailing.domain.igtimiadapter.test - com.sap.sailing.domain.racelogtrackingadapter.test - com.sap.sailing.xmlexport.test - com.sap.sailing.xrr.resultimport.test - com.sap.sailing.domain.shared.android.test - com.sap.sailing.geocoding.test - com.sap.sailing.domain.swisstimingadapter.test - com.sap.sailing.domain.swisstimingreplayadapter.test - com.sap.sailing.declination.test - com.sap.sailing.expeditionconnector.test - com.sap.sailing.server.test - com.sap.sailing.server.gateway.test - com.sap.sailing.server.gateway.test.support - com.sap.sailing.server.gateway.serialization.test - com.sap.sailing.server.replication.test - com.sap.sailing.gwt.ui.test - com.sap.sailing.mongodb.test - com.googlecode.java-diff-utils.test - com.sap.sailing.kiworesultimport.test - com.sap.sailing.ess40.resultimport.test - com.sap.sailing.freg.resultimport.test - com.sap.sailing.barbados.resultimport - com.sap.sailing.barbados.resultimport.test - com.sap.sailing.velum.resultimport - com.sap.sailing.velum.resultimport.test - com.sap.sailing.sailwave.resultimport - com.sap.sailing.sailwave.resultimport.test - com.sap.sailing.manage2sail - com.sap.sailing.manage2sail.resultimport - com.sap.sailing.manage2sail.resultimport.test - com.sap.sailing.simulator.test - com.sap.sailing.server.trackfiles.test - com.sap.sailing.selenium.test - com.sap.sailing.autoload - com.sap.sailing.feature.p2build - com.sap.sailing.polars - com.sap.sailing.polars.datamining - com.sap.sailing.polars.datamining.shared - com.sap.sailing.polars.test - - - - - - org.eclipse.tycho - target-platform-configuration - - - - - eclipse-plugin - com.google.gwt.dev - 0.0.0 - - - - - - - - - - no-debug.with-proxy - - true - - - - ${parameters.common} ${parameters.vm-settings} ${parameters.proxy} ${parameters.tractrac} ${parameters.mongodb} - - - - - no-debug.without-proxy - - - ${parameters.common} ${parameters.vm-settings} ${parameters.mongodb} - - - - - debug.with-proxy - - - ${parameters.common} ${parameters.vm-settings} ${parameters.proxy} ${parameters.debug} ${parameters.mongodb} - - - - - debug.without-proxy - - - ${parameters.common} ${parameters.vm-settings} ${parameters.debug} ${parameters.mongodb} - - - - - p2-target.local - - - race-analysis-p2-local - - - - - p2-local - - - - - - leandi - - - - ldi.releaseBuild - - - - - race-analysis-p2-empty - - - - - com.sap.sailing - install-android-sdk - ${project.version} - provided - pom - - - - - - org.eclipse.tycho - tycho-compiler-plugin - - - 1.7 - 1.7 - - - - - - - - non-leandi - - - - !ldi.releaseBuild - - - - - - - org.eclipse.tycho - tycho-compiler-plugin - - BREE - - - - - - - - - bin - bin - bin - - - - - true - org.eclipse.tycho - eclipse-test-plugin - ${tycho-version} - - - org.apache.maven.plugins - maven-surefire-plugin - 2.16 - - ${reportsdirectory} - - - - com.simpligility.maven.plugins - android-maven-plugin - - src - AndroidManifest.xml - - *.jar - generated-sources/** - maven-archiver/** - sourcebundle-l10n-gen/** - p2* - MANIFEST.MF - *.ap_ - local-artifacts.properties - **/*.gwt.xml - - - - - aar - - aar - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.9.1 - - - package - - attach-artifact - - - - - aar - ${project.build.directory}/${project.build.finalName}.aar - - - - - - - - - - - - org.eclipse.tycho - tycho-maven-plugin - ${tycho-version} - true - - - org.eclipse.tycho - target-platform-configuration - ${tycho-version} - - p2 - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ../com.sap.sailing.targetplatform/definitions/${p2-target} - - - - - linux - gtk - x86 - - - linux - gtk - x86_64 - - - win32 - win32 - x86 - - - win32 - win32 - x86_64 - - - macosx - cocoa - x86_64 - - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - ${tycho.build.argLine} - - - **/*$* - - ${reportsdirectory} - - - - org.eclipse.tycho - tycho-compiler-plugin - ${tycho-version} - - - - - org.codehaus.mojo - gwt-maven-plugin - ${gwt.version} - - - - - -Dgwt.persistentunitcache=false -Xmx2048m -Djava.io.tmpdir=${env.TMP} - - - ${gwt.workers} - - - - - - - - - - - - org.apache.maven.wagon - wagon-ssh-external - 1.0-beta-6 - - - - - - - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.16 - - true - - ${reportsdirectory} - true - - - - - - + + + 4.0.0 + + + workspace + com.sap.sailing + 1.0.0-SNAPSHOT + + + root + pom + + + + com.sap.sse.common + com.sap.sse.shared.android + com.sap.sse.datamining.annotations + com.sap.sse.security.common + org.json.simple + com.sap.sailing.domain.common + com.sap.sailing.domain.shared.android + com.sap.sailing.server.gateway.serialization.shared.android + + + + 0.21.0 + 2.7.0 + 2.7.0 + 2 + race-analysis-p2-remote + + + -Dfile.encoding=cp1252 -Dmongo.dbName=winddbTest -DspatialWind=true + + + -ea -Xmx1024m -XX:+UseG1GC + + + -Dtractrac.tunnel=true -Dtractrac.tunnel.host=localhost + + + -Dmongo.host=127.0.0.1 + + + -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y + + + + -Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.wdf.sap.corp -Dhttps.proxyPort=8080 + + ${project.build.directory}/surefire-reports + false + + + + + + with-not-android-relevant + + + !ldi.releaseBuild + + + + com.sap.sse + com.sap.sse.mail + com.sap.sse.mail.replication.test + com.sap.sse.mail.replication.testsupport + com.sap.sse.mongodb + com.sap.sse.gwt + com.sap.sse.gwt.adminconsole + com.sap.sse.datamining + com.sap.sse.datamining.shared + com.sap.sse.security + com.sap.sse.security.ui + com.sap.sse.security.userstore.mongodb + com.sap.sse.operationaltransformation + com.sap.sse.replication + com.sap.sse.threadmanager + com.sap.sse.filestorage + com.sap.sailing.domain + com.sap.sailing.geocoding + com.sap.sailing.datamining + com.sap.sailing.datamining.shared + com.sap.sailing.domain.persistence + com.sap.sailing.domain.deckmanadapter + com.sap.sailing.domain.tractracadapter + com.sap.sailing.domain.tractracadapter.persistence + com.sap.sailing.domain.igtimiadapter + com.sap.sailing.domain.igtimiadapter.persistence + com.sap.sailing.domain.racelogtrackingadapter + com.sap.sailing.domain.racelogtrackingadapter.testsupport + com.sap.sailing.domain.swisstimingadapter + com.sap.sailing.domain.swisstimingadapter.persistence + com.sap.sailing.domain.swisstimingreplayadapter + com.sap.sailing.news + com.sap.sailing.declination + com.sap.sailing.udpconnector + com.sap.sailing.expeditionconnector + com.sap.sailing.server + com.sap.sailing.server.gateway + com.sap.sailing.server.gateway.serialization + com.sap.sailing.www + com.sap.sailing.xmlexport + com.google.gwt.dev + com.google.gwt.osgi + com.tractrac.clientmodule + com.googlecode.java-diff-utils + com.googlecode.mgwt + com.sap.sailing.dashboards.gwt + com.sap.sailing.feature + org.moxieapps.gwt.highcharts + com.sap.sailing.resultimport + com.sap.sailing.kiworesultimport + com.sap.sailing.ess40.resultimport + com.sap.sailing.xrr.schema + com.sap.sailing.xrr.resultimport + com.sap.sailing.xrr.structureimport + com.sap.sailing.freg.resultimport + org.openqa.selenium.osgi + com.sap.sailing.monitoring + com.sap.sailing.simulator + com.sap.sailing.server.trackfiles + com.sap.sailing.feature.runtime + com.sap.sailing.gwt.ui + com.sap.sailing.domain.test + com.sap.sse.replication.testsupport + + com.sap.sse.gwt.test + + com.sap.sse.datamining.test + com.sap.sse.security.replication.test + com.sap.sse.security.test + com.sap.sse.operationaltransformation.test + com.sap.sse.common.test + com.sap.sse.filestorage.test + com.sap.sailing.datamining.test + com.sap.sailing.domain.deckmanadapter.test + com.sap.sailing.domain.igtimiadapter.test + com.sap.sailing.domain.racelogtrackingadapter.test + com.sap.sailing.xmlexport.test + com.sap.sailing.xrr.resultimport.test + com.sap.sailing.domain.shared.android.test + com.sap.sailing.geocoding.test + com.sap.sailing.domain.swisstimingadapter.test + com.sap.sailing.domain.swisstimingreplayadapter.test + com.sap.sailing.declination.test + com.sap.sailing.expeditionconnector.test + com.sap.sailing.server.test + com.sap.sailing.server.gateway.test + com.sap.sailing.server.gateway.test.support + com.sap.sailing.server.gateway.serialization.test + com.sap.sailing.server.replication.test + com.sap.sailing.gwt.ui.test + com.sap.sailing.mongodb.test + com.googlecode.java-diff-utils.test + com.sap.sailing.kiworesultimport.test + com.sap.sailing.ess40.resultimport.test + com.sap.sailing.freg.resultimport.test + com.sap.sailing.barbados.resultimport + com.sap.sailing.barbados.resultimport.test + com.sap.sailing.velum.resultimport + com.sap.sailing.velum.resultimport.test + com.sap.sailing.sailwave.resultimport + com.sap.sailing.sailwave.resultimport.test + com.sap.sailing.manage2sail + com.sap.sailing.manage2sail.resultimport + com.sap.sailing.manage2sail.resultimport.test + com.sap.sailing.yachtscoring + com.sap.sailing.yachtscoring.resultimport + com.sap.sailing.yachtscoring.resultimport.test + com.sap.sailing.simulator.test + com.sap.sailing.server.trackfiles.test + com.sap.sailing.selenium.test + com.sap.sailing.autoload + com.sap.sailing.feature.p2build + com.sap.sailing.polars + com.sap.sailing.polars.datamining + com.sap.sailing.polars.datamining.shared + com.sap.sailing.polars.test + + + + + + org.eclipse.tycho + target-platform-configuration + + + + + eclipse-plugin + com.google.gwt.dev + 0.0.0 + + + + + + + + + + no-debug.with-proxy + + true + + + + ${parameters.common} ${parameters.vm-settings} ${parameters.proxy} ${parameters.tractrac} ${parameters.mongodb} + + + + + no-debug.without-proxy + + + ${parameters.common} ${parameters.vm-settings} ${parameters.mongodb} + + + + + debug.with-proxy + + + ${parameters.common} ${parameters.vm-settings} ${parameters.proxy} ${parameters.debug} ${parameters.mongodb} + + + + + debug.without-proxy + + + ${parameters.common} ${parameters.vm-settings} ${parameters.debug} ${parameters.mongodb} + + + + + p2-target.local + + + race-analysis-p2-local + + + + + p2-local + + + + + + leandi + + + + ldi.releaseBuild + + + + + race-analysis-p2-empty + + + + + com.sap.sailing + install-android-sdk + ${project.version} + provided + pom + + + + + + org.eclipse.tycho + tycho-compiler-plugin + + + 1.7 + 1.7 + + + + + + + + non-leandi + + + + !ldi.releaseBuild + + + + + + + org.eclipse.tycho + tycho-compiler-plugin + + BREE + + + + + + + + + bin + bin + bin + + + + + true + org.eclipse.tycho + eclipse-test-plugin + ${tycho-version} + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + ${reportsdirectory} + + + + com.simpligility.maven.plugins + android-maven-plugin + + src + AndroidManifest.xml + + *.jar + generated-sources/** + maven-archiver/** + sourcebundle-l10n-gen/** + p2* + MANIFEST.MF + *.ap_ + local-artifacts.properties + **/*.gwt.xml + + + + + aar + + aar + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + package + + attach-artifact + + + + + aar + ${project.build.directory}/${project.build.finalName}.aar + + + + + + + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ../com.sap.sailing.targetplatform/definitions/${p2-target} + + + + + linux + gtk + x86 + + + linux + gtk + x86_64 + + + win32 + win32 + x86 + + + win32 + win32 + x86_64 + + + macosx + cocoa + x86_64 + + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + ${tycho.build.argLine} + + + **/*$* + + ${reportsdirectory} + + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho-version} + + + + + org.codehaus.mojo + gwt-maven-plugin + ${gwt.version} + + + + + -Dgwt.persistentunitcache=false -Xmx2048m -Djava.io.tmpdir=${env.TMP} + + + ${gwt.workers} + + + + + + + + + + + + org.apache.maven.wagon + wagon-ssh-external + 1.0-beta-6 + + + + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.16 + + true + + ${reportsdirectory} + true + + + + + + From 508075fe1caf8c955ffa8b73b0f49378fb41f1a5 Mon Sep 17 00:00:00 2001 From: fmittag Date: Thu, 10 Mar 2016 16:01:01 +0100 Subject: [PATCH 020/178] added yachtscoring bundles to all launch configs --- java/com.sap.sailing.server/SailingServer (No Proxy OSX).launch | 2 +- java/com.sap.sailing.server/SailingServer (No Proxy).launch | 2 +- .../SailingServer (No Proxy, Cached MTB).launch | 2 +- .../SailingServer (No Proxy, Jetty on 8889).launch | 2 +- .../SailingServer (No Proxy, Jetty on 8889, Cached MTB).launch | 2 +- ...gServer (No Proxy, Jetty on 8889, auto-replicate dev).launch | 2 +- ...ilingServer (No Proxy, Jetty on 8889, auto-replicate).launch | 2 +- .../SailingServer (No Proxy, Jetty on 8890).launch | 2 +- .../SailingServer (No Proxy, Remote Debug SAP VM).launch | 2 +- .../SailingServer (No Proxy, winddbTest).launch | 2 +- java/com.sap.sailing.server/SailingServer (Proxy).launch | 2 +- .../SailingServer (Proxy, Jetty on 8889).launch | 2 +- .../SailingServer (Proxy, Remote Debug SAP VM).launch | 2 +- .../SailingServer (Proxy, SwissTiming Live Simulation).launch | 2 +- .../SailingServer (Proxy, winddbTest).launch | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy OSX).launch b/java/com.sap.sailing.server/SailingServer (No Proxy OSX).launch index 70d5da234a1..c5fbebbd3b6 100644 --- a/java/com.sap.sailing.server/SailingServer (No Proxy OSX).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy OSX).launch @@ -34,5 +34,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy).launch b/java/com.sap.sailing.server/SailingServer (No Proxy).launch index fb49b67aa62..72580208907 100644 --- a/java/com.sap.sailing.server/SailingServer (No Proxy).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy).launch @@ -34,5 +34,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Cached MTB).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Cached MTB).launch index f423d629372..8fdd196df53 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Cached MTB).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Cached MTB).launch @@ -33,5 +33,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889).launch index a1b211da85d..461225d15fc 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889).launch @@ -27,6 +27,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, Cached MTB).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, Cached MTB).launch index 5fb70d15c55..53dabca1321 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, Cached MTB).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, Cached MTB).launch @@ -27,6 +27,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate dev).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate dev).launch index 7327c33673a..fc1df1f0d56 100644 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate dev).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate dev).launch @@ -27,6 +27,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate).launch index 3e59695678f..cd05536bb6e 100644 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8889, auto-replicate).launch @@ -27,6 +27,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8890).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8890).launch index 4c27b93091f..1cf49bb21f0 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8890).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Jetty on 8890).launch @@ -27,6 +27,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, Remote Debug SAP VM).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, Remote Debug SAP VM).launch index 09a44db1439..43a91809e94 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, Remote Debug SAP VM).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, Remote Debug SAP VM).launch @@ -27,5 +27,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy, winddbTest).launch b/java/com.sap.sailing.server/SailingServer (No Proxy, winddbTest).launch index a855c7db089..1738788cbaf 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy, winddbTest).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy, winddbTest).launch @@ -33,5 +33,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (Proxy).launch b/java/com.sap.sailing.server/SailingServer (Proxy).launch index c74298fb3be..6e6727e33e8 100755 --- a/java/com.sap.sailing.server/SailingServer (Proxy).launch +++ b/java/com.sap.sailing.server/SailingServer (Proxy).launch @@ -34,6 +34,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch index b19398528bb..89c4a94d064 100755 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch +++ b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch @@ -27,6 +27,6 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch index 57628771165..361e622bbb6 100755 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch +++ b/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch @@ -27,5 +27,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch b/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch index d9d2b3a236c..a31c9c3c0ce 100755 --- a/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch +++ b/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch @@ -26,5 +26,5 @@ - + diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch b/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch index 4e8e768c965..57fe2d1de6d 100755 --- a/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch +++ b/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch @@ -28,6 +28,6 @@ - + From beae63e4860813a94d55528875ada2f7b1a68099 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 16:41:57 +0100 Subject: [PATCH 021/178] Added debug ids for easier access to UI elements in selenium test cases --- .../sailing/gwt/ui/adminconsole/EventListComposite.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java index 7ec6d7471b3..64207b1e1e8 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java @@ -54,6 +54,7 @@ import com.sap.sse.gwt.client.ErrorReporter; import com.sap.sse.gwt.client.async.MarkedAsyncCallback; import com.sap.sse.gwt.client.celltable.EntityIdentityComparator; import com.sap.sse.gwt.client.celltable.RefreshableMultiSelectionModel; +import com.sap.sse.gwt.client.dialog.DataEntryDialog; import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback; import com.sap.sse.gwt.client.panels.LabeledAbstractFilterablePanel; @@ -682,7 +683,8 @@ public class EventListComposite extends Composite implements EventsRefresher, Le fillEvents(); if (newEvent.getLeaderboardGroups().isEmpty()) { // show simple Dialog - new CreateDefaultLeaderboardGroupDialog(sailingService, stringMessages, errorReporter, new DialogCallback() { + DataEntryDialog dialog = new CreateDefaultLeaderboardGroupDialog( + sailingService, stringMessages, errorReporter, new DialogCallback() { @Override public void ok(Void editedObject) { openLeaderboardGroupCreationDialog(existingLeaderboardGroups, newEvent); @@ -691,7 +693,9 @@ public class EventListComposite extends Composite implements EventsRefresher, Le @Override public void cancel() { } - }).show(); + }); + dialog.ensureDebugId("CreateDefaultLeaderboardGroupConfirmDialog"); + dialog.show(); } else { openCreateDefaultRegattaDialog(newEvent); } From 868454a5a66b353a03e346dab31c2395599896d3 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 16:42:33 +0100 Subject: [PATCH 022/178] Added pages object for simple confirmation dialogs --- .../pages/common/ConfirmDialogPO.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/ConfirmDialogPO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/ConfirmDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/ConfirmDialogPO.java new file mode 100644 index 00000000000..8b5ae6afe55 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/ConfirmDialogPO.java @@ -0,0 +1,20 @@ +package com.sap.sailing.selenium.pages.common; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +public class ConfirmDialogPO extends DataEntryDialogPO { + + public ConfirmDialogPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public void pressYes() { + super.pressOk(); + } + + public void pressNo() { + super.pressCancel(); + } + +} From 5c12599994eb111ecf630c878f49932e3058ed27 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 16:43:30 +0100 Subject: [PATCH 023/178] Added convenience method for easier dialog access to PageObject class --- .../src/com/sap/sailing/selenium/pages/PageObject.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java index 907dfc7246e..585b6760872 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java @@ -22,6 +22,7 @@ import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.core.FindBys; import com.sap.sailing.selenium.core.SeleniumElementLocatorFactory; import com.sap.sailing.selenium.core.SeleniumFieldDecorator; +import com.sap.sailing.selenium.pages.common.DataEntryDialogPO; /** *

Within a web app's UI there are areas that tests interact with. A page object simply models these as objects @@ -403,4 +404,12 @@ public class PageObject { protected void waitUtil(BooleanSupplier supplier) { waitUtil((driver) -> supplier.getAsBoolean()); } + + protected D getDialog(DialogPOSupplier supplier, String seleniumId) { + return supplier.get(driver, findElementBySeleniumId(driver, seleniumId)); + } + + protected interface DialogPOSupplier { + T get(WebDriver driver, WebElement element); + } } From ffa30b06510cfba7eb5ede0f0ba6d263e02ce5a5 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 16:45:07 +0100 Subject: [PATCH 024/178] Extended page object for event config to access list entries --- .../event/EventConfigurationPanelPO.java | 42 +++++++++++++++++-- .../pages/common/DataEntryDialogPO.java | 3 +- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java index 3e0be4d7c63..83b68dbfd21 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -2,15 +2,36 @@ package com.sap.sailing.selenium.pages.adminconsole.event; import java.util.Date; +import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.pages.PageArea; +import com.sap.sailing.selenium.pages.common.ConfirmDialogPO; +import com.sap.sailing.selenium.pages.gwt.CellTablePO; +import com.sap.sailing.selenium.pages.gwt.DataEntryPO; +import com.sap.sailing.selenium.pages.gwt.GenericCellTablePO; public class EventConfigurationPanelPO extends PageArea { + public static class EventEntryPO extends DataEntryPO { + + public EventEntryPO(CellTablePO table, WebElement element) { + super(table, element); + } + + @Override + public String getIdentifier() { + return getColumnContent("Event"); + } + + public String getEventURL() { + return getWebElement().findElement(By.xpath(".//td/div/a")).getAttribute("href"); + } + } + @FindBy(how = BySeleniumId.class, using = "RefreshEventsButton") private WebElement refreshEventsButton; @@ -19,15 +40,28 @@ public class EventConfigurationPanelPO extends PageArea { @FindBy(how = BySeleniumId.class, using = "RemoveEventsButton") private WebElement removeEventsButton; + + @FindBy(how = BySeleniumId.class, using = "EventsCellTable") + private WebElement eventsCellTable; public EventConfigurationPanelPO(WebDriver driver, WebElement element) { super(driver, element); } - public void createPublicEvent(String name, String venue, Date startDate, Date endDate) { + public void createSimplePublicEvent(String name, String venue, Date startDate, Date endDate) { createEventButton.click(); - EventCreateDialogPO dialog = new EventCreateDialogPO(driver, findElementBySeleniumId(driver, "EventCreateDialog")); - dialog.createEvent(name, "", venue, startDate, endDate, true); + EventCreateDialogPO createDialog = getDialog(EventCreateDialogPO::new, "EventCreateDialog"); + createDialog.createEvent(name, "", venue, startDate, endDate, true); + ConfirmDialogPO confirmDialog = getDialog(ConfirmDialogPO::new, "CreateDefaultLeaderboardGroupConfirmDialog"); + confirmDialog.pressNo(); } - + + public EventEntryPO getEventEntry(String event) { + return getEventsTable().getEntry(event); + } + + private CellTablePO getEventsTable() { + return new GenericCellTablePO<>(this.driver, this.eventsCellTable, EventEntryPO.class); + } + } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java index 504786e69e4..5fb83e7af97 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java @@ -20,8 +20,7 @@ public abstract class DataEntryDialogPO extends PageArea { @FindBy(how = BySeleniumId.class, using = "CancelButton") private WebElement cancelButton; - - public DataEntryDialogPO(WebDriver driver, WebElement element) { + protected DataEntryDialogPO(WebDriver driver, WebElement element) { super(driver, element); } From fc7c981a48eea829fd6606f142bfc4eb3337af16 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 17:09:26 +0100 Subject: [PATCH 025/178] Added convenience method for easier URL query handling to HostPage class --- .../sap/sailing/selenium/pages/HostPage.java | 19 ++++++++++++++++++- .../pages/adminconsole/AdminConsolePage.java | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java index 145fe69a903..ab344d8b149 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java @@ -1,5 +1,8 @@ package com.sap.sailing.selenium.pages; +import java.net.URI; +import java.net.URISyntaxException; + import org.openqa.selenium.WebDriver; /** @@ -9,7 +12,7 @@ import org.openqa.selenium.WebDriver; * @author * D049941 */ -public class HostPage extends PageObject { +public abstract class HostPage extends PageObject { protected static final String GWT_CODE_SERVER_PARAMETER_NAME = "gwt.codesvr"; //$NON-NLS-1$ protected static final String NO_CODE_SERVER_PARAMTER_VALUE = ""; //$NON-NLS-1$ @@ -27,6 +30,20 @@ public class HostPage extends PageObject { return GWT_CODE_SERVER_PARAMETER_NAME + "=" + codeServer; } + protected static void goToUrl(WebDriver driver, String url) { + try { + goToPage(driver, new URI(url)); + } catch (URISyntaxException exc) { + throw new IllegalArgumentException(exc); + } + } + + private static final void goToPage(WebDriver driver, URI uri) throws URISyntaxException { + String scheme = uri.getScheme(), userInfo = uri.getUserInfo(), host = uri.getHost(); + String path = uri.getPath(), query = getGWTCodeServer(), fragment = uri.getFragment(); + driver.get(new URI(scheme, userInfo, host, uri.getPort(), path, query, fragment).toString()); + } + /** *

Creates a new page object with the given web driver. In GWT an entry point is connected to a HTML page in * which the code for the application is executed, whereby the page is represented by the web driver.

diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java index 544f0c855c4..f684b32e852 100755 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java @@ -14,6 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.ElementSearchConditions; import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.HostPage; import com.sap.sailing.selenium.pages.HostPageWithAuthentication; import com.sap.sailing.selenium.pages.adminconsole.connectors.SmartphoneTrackingEventManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; @@ -84,7 +85,7 @@ public class AdminConsolePage extends HostPageWithAuthentication { * The page object for the administration console. */ public static AdminConsolePage goToPage(WebDriver driver, String root) { - driver.get(root + "gwt/AdminConsole.html?" + getGWTCodeServer()); //$NON-NLS-1$ + HostPage.goToUrl(driver, root + "gwt/AdminConsole.html"); return new AdminConsolePage(driver); } From 21ab9aaaa36569cd75454dee8ad289920e18d29e Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 17:10:05 +0100 Subject: [PATCH 026/178] Adjusted pages object stub for SAP Sailing home page --- .../sailing/selenium/pages/home/HomePage.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java new file mode 100644 index 00000000000..40d28076812 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java @@ -0,0 +1,41 @@ +package com.sap.sailing.selenium.pages.home; + +import org.openqa.selenium.WebDriver; + +import com.sap.sailing.selenium.pages.HostPage; +import com.sap.sailing.selenium.pages.HostPageWithAuthentication; +import com.sap.sailing.selenium.pages.PageObject; + +/** + * {@link PageObject} representing the SAP Sailing home page. + */ +public class HomePage extends HostPageWithAuthentication { + + /** + * Navigates to the home page and provides the corresponding {@link PageObject}. + * + * @param driver the {@link WebDriver} to use + * @param root the context root of the application + * @return the {@link PageObject} for the home page + */ + public static HomePage goToPage(WebDriver driver, String root) { + return goToHomeUrl(driver, root + "gwt/Home.html"); + } + + /** + * Navigates to the given home URL and provides the corresponding {@link PageObject}. + * + * @param driver the {@link WebDriver} to use + * @param url the desired destination URL + * @return the {@link PageObject} for the home page + */ + public static HomePage goToHomeUrl(WebDriver driver, String url) { + HostPage.goToUrl(driver, url); + return new HomePage(driver); + } + + private HomePage(WebDriver driver) { + super(driver); + } + +} From 10c0e8e7ac25a28b0dfd97ed5f4503d42561e2d5 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 17:11:22 +0100 Subject: [PATCH 027/178] Extended selenium test stub for event state visualisation --- .../integration/state/TestStateVisualisationEvent.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java index 230f9829e44..2b98d60044b 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java @@ -7,6 +7,7 @@ import org.junit.Test; import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; +import com.sap.sailing.selenium.pages.home.HomePage; import com.sap.sailing.selenium.test.AbstractSeleniumTest; public class TestStateVisualisationEvent extends AbstractSeleniumTest { @@ -18,10 +19,12 @@ public class TestStateVisualisationEvent extends AbstractSeleniumTest { } @Test - public void testStateFlagOfUmcomingEvent() { + public void testStateFlagOfUpcomingEvent() { AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); EventConfigurationPanelPO eventConfigurationPanel = adminConsolePage.goToEvents(); - eventConfigurationPanel.createPublicEvent("Test", "Somewhere", new Date(), new Date()); + eventConfigurationPanel.createSimplePublicEvent("Test", "Somewhere", new Date(), new Date()); + String eventUrl = eventConfigurationPanel.getEventEntry("Test").getEventURL(); + HomePage.goToHomeUrl(getWebDriver(), eventUrl); Assert.assertTrue(true); } From 78435129cf16f101009d6cffcfd072513f91b822 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Thu, 10 Mar 2016 17:53:36 +0100 Subject: [PATCH 028/178] Refactored convenience method for easier dialog access to allow access to any PageArea --- .../sap/sailing/selenium/pages/PageArea.java | 1 + .../sailing/selenium/pages/PageObject.java | 30 +++++++++++++++++-- .../event/EventConfigurationPanelPO.java | 4 +-- .../authentication/AuthenticationMenuPO.java | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageArea.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageArea.java index 0e9575ec3ea..7ee8f376b44 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageArea.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageArea.java @@ -32,4 +32,5 @@ public class PageArea extends PageObject { public WebElement getWebElement() { return (WebElement) this.context; } + } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java index 585b6760872..be84ce7fe55 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java @@ -22,7 +22,6 @@ import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.core.FindBys; import com.sap.sailing.selenium.core.SeleniumElementLocatorFactory; import com.sap.sailing.selenium.core.SeleniumFieldDecorator; -import com.sap.sailing.selenium.pages.common.DataEntryDialogPO; /** *

Within a web app's UI there are areas that tests interact with. A page object simply models these as objects @@ -405,11 +404,36 @@ public class PageObject { waitUtil((driver) -> supplier.getAsBoolean()); } - protected D getDialog(DialogPOSupplier supplier, String seleniumId) { + /** + * Returns a {@link PageArea} instance representing the element with the specified selenium id using the + * {@link WebDriver} as search context. + * + * @param supplier {@link PageAreaSupplier} used to instantiate the {@link PageArea} + * @param seleniumId the selenium id of the desired element + * @return {@link PageArea} representing the first matching element + * + * @see #findElementBySeleniumId(SearchContext, String) + */ + protected T getPO(PageAreaSupplier supplier, String seleniumId) { return supplier.get(driver, findElementBySeleniumId(driver, seleniumId)); } - protected interface DialogPOSupplier { + /** + * Returns a {@link PageArea} instance representing the element with the specified selenium id in the search + * context of this page area. + * + * @param supplier {@link PageAreaSupplier} used to instantiate the {@link PageArea} + * @param seleniumId the selenium id of the desired element + * @return {@link PageArea} representing the first matching element + * + * @see #findElementBySeleniumId(String) + */ + protected T getChildPO(PageAreaSupplier supplier, String seleniumId) { + return supplier.get(driver, findElementBySeleniumId(seleniumId)); + } + + protected interface PageAreaSupplier { T get(WebDriver driver, WebElement element); } + } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java index 83b68dbfd21..8e1e9ce24b6 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -50,9 +50,9 @@ public class EventConfigurationPanelPO extends PageArea { public void createSimplePublicEvent(String name, String venue, Date startDate, Date endDate) { createEventButton.click(); - EventCreateDialogPO createDialog = getDialog(EventCreateDialogPO::new, "EventCreateDialog"); + EventCreateDialogPO createDialog = getPO(EventCreateDialogPO::new, "EventCreateDialog"); createDialog.createEvent(name, "", venue, startDate, endDate, true); - ConfirmDialogPO confirmDialog = getDialog(ConfirmDialogPO::new, "CreateDefaultLeaderboardGroupConfirmDialog"); + ConfirmDialogPO confirmDialog = getPO(ConfirmDialogPO::new, "CreateDefaultLeaderboardGroupConfirmDialog"); confirmDialog.pressNo(); } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java index aba8b187cd9..c4b01aa068c 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java @@ -29,7 +29,7 @@ public class AuthenticationMenuPO extends PageArea { private AuthenticationViewPO showAuthenticationView() { getWebElement().click(); waitUtil(this::isOpen); - return new AuthenticationViewPO(driver, findElementBySeleniumId(driver, "authenticationView")); + return getPO(AuthenticationViewPO::new, "authenticationView"); } } From b008f2cad4f413b6ad77e6fdddbe17c711f63762 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Fri, 11 Mar 2016 15:41:25 +0100 Subject: [PATCH 029/178] Added convenience method to access host page objects via url --- .../src/com/sap/sailing/selenium/pages/HostPage.java | 7 ++++++- .../selenium/pages/adminconsole/AdminConsolePage.java | 3 +-- .../src/com/sap/sailing/selenium/pages/home/HomePage.java | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java index ab344d8b149..40e01f6ce29 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java @@ -30,9 +30,10 @@ public abstract class HostPage extends PageObject { return GWT_CODE_SERVER_PARAMETER_NAME + "=" + codeServer; } - protected static void goToUrl(WebDriver driver, String url) { + protected final static T goToUrl(HostPageSupplier supplier, WebDriver driver, String url) { try { goToPage(driver, new URI(url)); + return supplier.get(driver); } catch (URISyntaxException exc) { throw new IllegalArgumentException(exc); } @@ -70,4 +71,8 @@ public abstract class HostPage extends PageObject { protected int getPageLoadTimeOut() { return DEFAULT_PAGE_LOAD_TIMEOUT; } + + protected interface HostPageSupplier { + T get(WebDriver driver); + } } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java index f684b32e852..f0a56110732 100755 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/AdminConsolePage.java @@ -85,8 +85,7 @@ public class AdminConsolePage extends HostPageWithAuthentication { * The page object for the administration console. */ public static AdminConsolePage goToPage(WebDriver driver, String root) { - HostPage.goToUrl(driver, root + "gwt/AdminConsole.html"); - return new AdminConsolePage(driver); + return HostPage.goToUrl(AdminConsolePage::new, driver, root + "gwt/AdminConsole.html"); } @FindBy(how = BySeleniumId.class, using = "AdministrationTabs") diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java index 40d28076812..43913f76084 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/HomePage.java @@ -30,8 +30,7 @@ public class HomePage extends HostPageWithAuthentication { * @return the {@link PageObject} for the home page */ public static HomePage goToHomeUrl(WebDriver driver, String url) { - HostPage.goToUrl(driver, url); - return new HomePage(driver); + return HostPage.goToUrl(HomePage::new, driver, url); } private HomePage(WebDriver driver) { From 69610137451781f85b3db2a4f7393e7cfe79530c Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Fri, 11 Mar 2016 15:41:53 +0100 Subject: [PATCH 030/178] Added debug ids for easier access to UI elements in selenium test cases --- .../gwt/home/desktop/partials/eventheader/EventHeader.java | 3 +++ .../gwt/home/desktop/partials/eventheader/EventHeader.ui.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.java index 44c10e1f1f9..d6170b2f01f 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.java @@ -15,6 +15,7 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.UIObject; import com.google.gwt.user.client.ui.Widget; import com.sap.sailing.gwt.common.client.i18n.TextMessages; import com.sap.sailing.gwt.home.communication.eventview.EventViewDTO; @@ -157,10 +158,12 @@ public class EventHeader extends Composite { if(!presenter.needsSelectionInHeader()) { eventName.setInnerText(nameToShow); LabelTypeUtil.renderLabelType(eventState, event.getState().getStateMarker()); + UIObject.ensureDebugId(eventState, "EventStateLabelDiv"); hide(dropdownTitle); } else { dropdownEventName.setInnerText(nameToShow); LabelTypeUtil.renderLabelType(dropdownEventState, presenter.showRegattaMetadata() ? presenter.getRegattaMetadata().getState().getStateMarker() : event.getState().getStateMarker()); + UIObject.ensureDebugId(dropdownEventState, "EventStateLabelDiv"); hide(staticTitle); initDropdown(); } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.ui.xml b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.ui.xml index 6f98e5881ac..bf98f60fd23 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.ui.xml +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/eventheader/EventHeader.ui.xml @@ -4,7 +4,7 @@ - +

From caecb3c85a8a3ebd815d9496fb4e921413233bcd Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Fri, 11 Mar 2016 15:43:23 +0100 Subject: [PATCH 031/178] Added page objects for event page, event header and label types --- .../selenium/pages/common/LabelTypePO.java | 41 +++++++++++++++++++ .../pages/home/event/EventHeaderPO.java | 19 +++++++++ .../selenium/pages/home/event/EventPage.java | 30 ++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventHeaderPO.java create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java new file mode 100644 index 00000000000..1b165983b91 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java @@ -0,0 +1,41 @@ +package com.sap.sailing.selenium.pages.common; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageArea; + +public class LabelTypePO extends PageArea { + + private static final String LABEL_TYPE_LIVE = "live"; + private static final String LABEL_TYPE_FINISHED = "finished"; + private static final String LABEL_TYPE_INPROGRESS = "proress"; + private static final String LABEL_TYPE_UPCOMING = "upcoming"; + + public LabelTypePO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public boolean isLive() { + return hasType(LABEL_TYPE_LIVE); + } + + public boolean isFinished() { + return hasType(LABEL_TYPE_FINISHED); + } + + public boolean isInProgress() { + return hasType(LABEL_TYPE_INPROGRESS); + } + + public boolean isUpcoming() { + return hasType(LABEL_TYPE_UPCOMING); + } + + private boolean hasType(String expectedType) { + String actualType = getWebElement().getAttribute("data-labeltype"); + return expectedType.equalsIgnoreCase(actualType); + } + + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventHeaderPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventHeaderPO.java new file mode 100644 index 00000000000..474816091cb --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventHeaderPO.java @@ -0,0 +1,19 @@ +package com.sap.sailing.selenium.pages.home.event; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageArea; +import com.sap.sailing.selenium.pages.common.LabelTypePO; + +public class EventHeaderPO extends PageArea { + + public EventHeaderPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public LabelTypePO getEventStateLabel() { + return getChildPO(LabelTypePO::new, "EventStateLabelDiv"); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java new file mode 100644 index 00000000000..12515a210c0 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java @@ -0,0 +1,30 @@ +package com.sap.sailing.selenium.pages.home.event; + +import org.openqa.selenium.WebDriver; + +import com.sap.sailing.selenium.pages.HostPage; +import com.sap.sailing.selenium.pages.HostPageWithAuthentication; +import com.sap.sailing.selenium.pages.PageObject; + +public class EventPage extends HostPageWithAuthentication { + + /** + * Navigates to the given home URL and provides the corresponding {@link PageObject}. + * + * @param driver the {@link WebDriver} to use + * @param url the desired destination URL + * @return the {@link PageObject} for the home page + */ + public static EventPage goToEventUrl(WebDriver driver, String url) { + return HostPage.goToUrl(EventPage::new, driver, url); + } + + private EventPage(WebDriver driver) { + super(driver); + } + + public EventHeaderPO getEventHeader() { + return getPO(EventHeaderPO::new, "EventHeaderPanel"); + } + +} From 8db4c5bb2a6db34e3e24599c20160c2cc508cd90 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Fri, 11 Mar 2016 16:10:55 +0100 Subject: [PATCH 032/178] Added null-check to TextBoxBasePO --- .../src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java index 1835366cb34..5a27fdd479d 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/TextBoxBasePO.java @@ -25,7 +25,9 @@ public abstract class TextBoxBasePO extends AbstractInputPO { * @see WebElement#sendKeys(CharSequence...) */ public void appendText(String text) { - getWebElement().sendKeys(text); + if (text != null) { + getWebElement().sendKeys(text); + } } /** From d7c956fed621f69d12b18425d31ba436569ec5ae Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Fri, 11 Mar 2016 16:11:32 +0100 Subject: [PATCH 033/178] Added helper class for date creation --- .../selenium/pages/common/DateHelper.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java new file mode 100644 index 00000000000..73af230dc09 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java @@ -0,0 +1,27 @@ +package com.sap.sailing.selenium.pages.common; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +public class DateHelper { + + public static Date getPastDate(int daysInPast) { + return getOffsetDate(-daysInPast); + } + + public static Date getCurrentDate() { + return getOffsetDate(0); + } + + public static Date getFutureDate(int daysInFuture) { + return getOffsetDate(daysInFuture); + } + + private static Date getOffsetDate(int offsetInDays) { + Calendar calendar = GregorianCalendar.getInstance(); + calendar.add(Calendar.DATE, offsetInDays); + return calendar.getTime(); + } + +} From 646760fd492e85fb882af786639d0f30f579e9d9 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Fri, 11 Mar 2016 16:59:53 +0100 Subject: [PATCH 034/178] Extended test case to test creation of upcoming, live and finished event --- .../event/EventConfigurationPanelPO.java | 11 ++++--- .../state/TestStateVisualisationEvent.java | 32 +++++++++++++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java index 8e1e9ce24b6..829f7676128 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -16,6 +16,9 @@ import com.sap.sailing.selenium.pages.gwt.GenericCellTablePO; public class EventConfigurationPanelPO extends PageArea { + private static final String ID_EVENT_CREATE_DIALOG = "EventCreateDialog"; + private static final String ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG = "CreateDefaultLeaderboardGroupConfirmDialog"; + public static class EventEntryPO extends DataEntryPO { public EventEntryPO(CellTablePO table, WebElement element) { @@ -48,11 +51,11 @@ public class EventConfigurationPanelPO extends PageArea { super(driver, element); } - public void createSimplePublicEvent(String name, String venue, Date startDate, Date endDate) { + public void createEmptyEvent(String name, String desc, String venue, Date startDate, Date endDate, boolean isPublic) { createEventButton.click(); - EventCreateDialogPO createDialog = getPO(EventCreateDialogPO::new, "EventCreateDialog"); - createDialog.createEvent(name, "", venue, startDate, endDate, true); - ConfirmDialogPO confirmDialog = getPO(ConfirmDialogPO::new, "CreateDefaultLeaderboardGroupConfirmDialog"); + EventCreateDialogPO createDialog = getPO(EventCreateDialogPO::new, ID_EVENT_CREATE_DIALOG); + createDialog.createEvent(name, desc, venue, startDate, endDate, isPublic); + ConfirmDialogPO confirmDialog = getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG); confirmDialog.pressNo(); } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java index 2b98d60044b..cd1056437c3 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java @@ -1,17 +1,22 @@ package com.sap.sailing.selenium.test.integration.state; +import static com.sap.sailing.selenium.pages.common.DateHelper.getFutureDate; +import static com.sap.sailing.selenium.pages.common.DateHelper.getPastDate; + import java.util.Date; +import java.util.function.Predicate; import org.junit.Assert; import org.junit.Test; import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; -import com.sap.sailing.selenium.pages.home.HomePage; +import com.sap.sailing.selenium.pages.common.LabelTypePO; +import com.sap.sailing.selenium.pages.home.event.EventPage; import com.sap.sailing.selenium.test.AbstractSeleniumTest; public class TestStateVisualisationEvent extends AbstractSeleniumTest { - + @Override public void setUp() { clearState(getContextRoot()); @@ -20,12 +25,27 @@ public class TestStateVisualisationEvent extends AbstractSeleniumTest { @Test public void testStateFlagOfUpcomingEvent() { + testStateFlagOfEvent("Test1", "Somewhere", getFutureDate(3), getFutureDate(7), LabelTypePO::isUpcoming); + } + + @Test + public void testStateFlagOfLiveEvent() { + testStateFlagOfEvent("Test2", "Somewhere else", getPastDate(3), getFutureDate(3), LabelTypePO::isLive); + } + + @Test + public void testStateFlagOfFinishedEvent() { + testStateFlagOfEvent("Test3", "Anywhere", getPastDate(7), getPastDate(3), LabelTypePO::isFinished); + } + + private void testStateFlagOfEvent(String name, String venue, Date startDate, Date endDate, + Predicate expectedLabelType) { AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); EventConfigurationPanelPO eventConfigurationPanel = adminConsolePage.goToEvents(); - eventConfigurationPanel.createSimplePublicEvent("Test", "Somewhere", new Date(), new Date()); - String eventUrl = eventConfigurationPanel.getEventEntry("Test").getEventURL(); - HomePage.goToHomeUrl(getWebDriver(), eventUrl); - Assert.assertTrue(true); + eventConfigurationPanel.createEmptyEvent(name, null, venue, startDate, endDate, true); + String eventUrl = eventConfigurationPanel.getEventEntry(name).getEventURL(); + EventPage eventPage = EventPage.goToEventUrl(getWebDriver(), eventUrl); + Assert.assertTrue(expectedLabelType.test(eventPage.getEventHeader().getEventStateLabel())); } } From d5dfc027b7ea73e6c05d4438a5e30e89cfc5b6f6 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 11:16:12 +0100 Subject: [PATCH 035/178] Added verification to EventPage to ensure page is loaded --- .../selenium/pages/home/event/EventPage.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java index 12515a210c0..4a465c53b9e 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java @@ -1,13 +1,18 @@ package com.sap.sailing.selenium.pages.home.event; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.pages.HostPage; import com.sap.sailing.selenium.pages.HostPageWithAuthentication; import com.sap.sailing.selenium.pages.PageObject; public class EventPage extends HostPageWithAuthentication { + private static final String EVENT_HEADER_IDENTIFIER = "EventHeaderPanel"; + /** * Navigates to the given home URL and provides the corresponding {@link PageObject}. * @@ -23,8 +28,14 @@ public class EventPage extends HostPageWithAuthentication { super(driver); } + @Override + protected void verify() { + WebDriverWait wait = new WebDriverWait(driver, DEFAULT_WAIT_TIMEOUT_SECONDS); + wait.until(ExpectedConditions.presenceOfElementLocated(new BySeleniumId(EVENT_HEADER_IDENTIFIER))); + } + public EventHeaderPO getEventHeader() { - return getPO(EventHeaderPO::new, "EventHeaderPanel"); + return getPO(EventHeaderPO::new, EVENT_HEADER_IDENTIFIER); } } From 76bf016d740962be67aefc39634643c10ef47334 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 12:16:57 +0100 Subject: [PATCH 036/178] Fixed typo in test class name --- ...VisualisationEvent.java => TestStateVisualizationEvent.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/{TestStateVisualisationEvent.java => TestStateVisualizationEvent.java} (96%) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationEvent.java similarity index 96% rename from java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java rename to java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationEvent.java index cd1056437c3..54b1fc192ff 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualisationEvent.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationEvent.java @@ -15,7 +15,7 @@ import com.sap.sailing.selenium.pages.common.LabelTypePO; import com.sap.sailing.selenium.pages.home.event.EventPage; import com.sap.sailing.selenium.test.AbstractSeleniumTest; -public class TestStateVisualisationEvent extends AbstractSeleniumTest { +public class TestStateVisualizationEvent extends AbstractSeleniumTest { @Override public void setUp() { From 47210094a556df8a16c319eefbb56cd4d0277854 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 12:56:15 +0100 Subject: [PATCH 037/178] Added debug ids for easier access to UI elements in selenium test cases --- .../adminconsole/AbstractRegattaWithSeriesAndFleetsDialog.java | 2 ++ .../sap/sailing/gwt/ui/adminconsole/CreateRegattaCallback.java | 2 +- .../com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractRegattaWithSeriesAndFleetsDialog.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractRegattaWithSeriesAndFleetsDialog.java index d098d2517ce..d4938a0a812 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractRegattaWithSeriesAndFleetsDialog.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractRegattaWithSeriesAndFleetsDialog.java @@ -73,8 +73,10 @@ public abstract class AbstractRegattaWithSeriesAndFleetsDialog extends DataEn } startDateBox = createDateTimeBox(regatta.startDate); startDateBox.setFormat("dd/mm/yyyy hh:ii"); + startDateBox.ensureDebugId("StartDateTimeBox"); endDateBox = createDateTimeBox(regatta.endDate); endDateBox.setFormat("dd/mm/yyyy hh:ii"); + endDateBox.ensureDebugId("EndDateTimeBox"); scoringSchemeListBox = createListBox(false); scoringSchemeListBox.ensureDebugId("ScoringSchemeListBox"); for (ScoringSchemeType scoringSchemeType : ScoringSchemeType.values()) { diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/CreateRegattaCallback.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/CreateRegattaCallback.java index 9dbd7153c72..628bb577a3c 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/CreateRegattaCallback.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/CreateRegattaCallback.java @@ -156,7 +156,7 @@ public class CreateRegattaCallback implements DialogCallback{ public void cancel() { } }); - dialog.ensureDebugId("CreateDefaultRegattaDialog"); + dialog.ensureDebugId("CreateDefaultRegattaLeaderboardDialog"); dialog.show(); } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java index 64207b1e1e8..1f4f6993874 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/EventListComposite.java @@ -562,6 +562,7 @@ public class EventListComposite extends Composite implements EventsRefresher, Le } }); leaderboardGroupCreateDialog.setFieldsBasedOnEventName(newEvent.getName()); + leaderboardGroupCreateDialog.ensureDebugId("LeaderboardGroupCreateDialog"); leaderboardGroupCreateDialog.show(); } From e3b4016f71b6ff0c376cbfb667c7eeb8a0200198 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 13:40:09 +0100 Subject: [PATCH 038/178] Added convenience method to BetterDateTimeBoxPO to set date objects --- .../pages/gwt/BetterDateTimeBoxPO.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java index ea380d4d316..8d54d61d428 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java @@ -1,5 +1,9 @@ package com.sap.sailing.selenium.pages.gwt; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -10,6 +14,8 @@ import com.sap.sailing.selenium.pages.PageObject; */ public class BetterDateTimeBoxPO extends TextBoxPO { + private static final DateFormat DATE_TIME_BOX_FORMAT = new SimpleDateFormat("dd/MM/yyyy hh:mm"); + /** * Factory method to create a {@link BetterDateTimeBoxPO}. * @@ -28,6 +34,19 @@ public class BetterDateTimeBoxPO extends TextBoxPO { super(driver, element); } + /** + * Sets the underlying {@link WebElement}s text by formatting the given {@link Date} using the internal date format + * (dd/MM/yyyy hh:mm). + * + * @param date the {@link Date} object to set + * + * @see DateFormat#format(Date) + * @see #setText(String) + */ + public void setDate(Date date) { + this.setText(DATE_TIME_BOX_FORMAT.format(date)); + } + @Override public void appendText(String text) { super.appendText(text); From 0547b1f4a8436f21de6042d1af29339bb6ed06f1 Mon Sep 17 00:00:00 2001 From: fmittag Date: Mon, 14 Mar 2016 15:15:16 +0100 Subject: [PATCH 039/178] updated the still broken xml output from yachtscoring --- .../event1390_KeyWestRaceWeek2016_xrr.xml | 5330 +++++++++++------ 1 file changed, 3577 insertions(+), 1753 deletions(-) diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml index c51883d4705..b65da1a9214 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml @@ -1,1754 +1,3578 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6ab4a5394b9f6b1c99c7f97e84a7c23a56ebeec6 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 16:18:22 +0100 Subject: [PATCH 040/178] Added debug ids for easier access to UI elements in selenium test cases --- .../partials/multiregattalist/MultiRegattaListItem.ui.xml | 2 +- .../home/desktop/partials/regattaheader/RegattaHeader.ui.xml | 2 +- .../desktop/partials/regattaheader/RegattaHeaderBody.java | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/multiregattalist/MultiRegattaListItem.ui.xml b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/multiregattalist/MultiRegattaListItem.ui.xml index 425f41a9517..7f2a49818ee 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/multiregattalist/MultiRegattaListItem.ui.xml +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/multiregattalist/MultiRegattaListItem.ui.xml @@ -5,7 +5,7 @@ - +
diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeader.ui.xml b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeader.ui.xml index eea06aea487..f7f28c63d07 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeader.ui.xml +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeader.ui.xml @@ -4,7 +4,7 @@ - +
diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java index 0d474310362..4d5b8c54215 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java @@ -11,8 +11,8 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.UIObject; import com.sap.sailing.gwt.common.client.BoatClassImageResolver; import com.sap.sailing.gwt.home.communication.event.LabelType; -import com.sap.sailing.gwt.home.communication.eventview.RegattaMetadataDTO; import com.sap.sailing.gwt.home.communication.eventview.HasRegattaMetadata.RegattaState; +import com.sap.sailing.gwt.home.communication.eventview.RegattaMetadataDTO; import com.sap.sailing.gwt.home.shared.utils.LabelTypeUtil; import com.sap.sailing.gwt.ui.client.StringMessages; @@ -44,6 +44,8 @@ public class RegattaHeaderBody extends UIObject { addDetailsItem(I18N.courseAreaName(defaultCourseAreaName)); } addDetailsItem(regattaMetadata.getBoatCategory()); + UIObject.ensureDebugId(labelUi, "RegattaStateLabelDiv"); + UIObject.ensureDebugId(nameUi, "RegattaNameDiv"); } private void addDetailsItem(int count, String text) { From 8493d21a7f57280818493f6b14aad4edf9286e00 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 16:19:10 +0100 Subject: [PATCH 041/178] Extended RegattaCreateDialogPO by adding date fields access --- .../regatta/RegattaCreateDialogPO.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java index 33a47d23ff9..bbd768e87e5 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java @@ -1,12 +1,15 @@ package com.sap.sailing.selenium.pages.adminconsole.regatta; +import java.util.Date; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.FindBy; - import com.sap.sailing.selenium.pages.common.DataEntryDialogPO; +import com.sap.sailing.selenium.pages.gwt.BetterDateTimeBoxPO; +import com.sap.sailing.selenium.pages.gwt.TextBoxPO; public class RegattaCreateDialogPO extends DataEntryDialogPO { @FindBy(how = BySeleniumId.class, using = "NameTextBox") @@ -15,6 +18,12 @@ public class RegattaCreateDialogPO extends DataEntryDialogPO { @FindBy(how = BySeleniumId.class, using = "BoatClassTextBox") private WebElement boatClassTextBox; + @FindBy(how = BySeleniumId.class, using = "StartDateTimeBox") + private WebElement startDateTimeBox; + + @FindBy(how = BySeleniumId.class, using = "EndDateTimeBox") + private WebElement endDateTimeBox; + // @FindBy(how = BySeleniumId.class, using = "ScoringSchemeListBox") // private WebElement scoringSystemDropDown; // @FindBy(how = BySeleniumId.class, using = "EventListBox") @@ -30,8 +39,7 @@ public class RegattaCreateDialogPO extends DataEntryDialogPO { } public void setRegattaName(String name) { - this.nameTextBox.clear(); - this.nameTextBox.sendKeys(name); + TextBoxPO.create(driver, nameTextBox).setText(name); } public void setBoatClass(String boatClass) { @@ -39,6 +47,13 @@ public class RegattaCreateDialogPO extends DataEntryDialogPO { this.boatClassTextBox.sendKeys(boatClass); } + public void setValues(String name, String boatClass, Date startDate, Date endDate) { + this.setRegattaName(name); + this.setBoatClass(boatClass); + BetterDateTimeBoxPO.create(driver, startDateTimeBox).setDate(startDate); + BetterDateTimeBoxPO.create(driver, endDateTimeBox).setDate(endDate); + } + // TODO: Scoring System, Event and Course Area public SeriesCreateDialogPO addSeries() { From 053549c87cc3b543c0f3d3a61dcecbb819282ee8 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 16:21:14 +0100 Subject: [PATCH 042/178] Adjusted EventCreateDialogPO date and workflow handling --- .../pages/adminconsole/event/EventCreateDialogPO.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java index da52c31ab09..8bcc815d8c5 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java @@ -1,7 +1,5 @@ package com.sap.sailing.selenium.pages.adminconsole.event; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.Date; import org.openqa.selenium.WebDriver; @@ -17,8 +15,6 @@ import com.sap.sailing.selenium.pages.gwt.TextBoxPO; public class EventCreateDialogPO extends DataEntryDialogPO { - private static final DateFormat DATE_TIME_BOX_FORMAT = new SimpleDateFormat("dd/MM/yyyy hh:mm"); - @FindBy(how = BySeleniumId.class, using = "NameTextBox") private WebElement nameTextBox; @@ -41,14 +37,13 @@ public class EventCreateDialogPO extends DataEntryDialogPO { super(driver, element); } - void createEvent(String name, String description, String venue, Date start, Date end, boolean isPublic) { + void setValues(String name, String description, String venue, Date start, Date end, boolean isPublic) { TextBoxPO.create(driver, nameTextBox).appendText(name); TextAreaPO.create(driver, descriptionTextArea).appendText(description); TextBoxPO.create(driver, venueTextBox).appendText(venue); - BetterDateTimeBoxPO.create(driver, startDateTimeBox).setText(DATE_TIME_BOX_FORMAT.format(start)); - BetterDateTimeBoxPO.create(driver, endDateTimeBox).setText(DATE_TIME_BOX_FORMAT.format(end)); + BetterDateTimeBoxPO.create(driver, startDateTimeBox).setDate(start); + BetterDateTimeBoxPO.create(driver, endDateTimeBox).setDate(end); CheckBoxPO.create(driver, isPublicCheckBox).setSelected(isPublic); - pressOk(); } } From 99e0a8104c6b7481619bef7c0768755cf9c51356 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 16:22:07 +0100 Subject: [PATCH 043/178] Added page objects for regatta list item on event, regatta and races pages --- .../pages/home/regatta/RegattaListItemPO.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java new file mode 100644 index 00000000000..3eb080350e0 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java @@ -0,0 +1,37 @@ +package com.sap.sailing.selenium.pages.home.regatta; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.PageArea; +import com.sap.sailing.selenium.pages.common.LabelTypePO; + +public class RegattaListItemPO extends PageArea { + + private final RegattaHeaderPO regattaHeader; + + public RegattaListItemPO(WebDriver driver, WebElement element) { + super(driver, element); + this.regattaHeader = getChildPO(RegattaHeaderPO::new, "RegattaHeaderPanel"); + } + + public RegattaHeaderPO getRegattaHeader() { + return regattaHeader; + } + + public class RegattaHeaderPO extends PageArea { + private RegattaHeaderPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public String getRegattaName() { + return findElementBySeleniumId("RegattaNameDiv").getText(); + } + + public LabelTypePO getRegattaStateLabel() { + return getChildPO(LabelTypePO::new, "RegattaStateLabelDiv"); + } + + } + +} From f096e6b820b3795552200e1e2f5abf4320388cc3 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 16:23:44 +0100 Subject: [PATCH 044/178] Extended EventConfigurationPanelPO to create events with default leaderboard group and regatta with default leaderboard --- .../event/EventConfigurationPanelPO.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java index 829f7676128..cfc2f28888e 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -9,6 +9,8 @@ import org.openqa.selenium.WebElement; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.pages.PageArea; +import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardGroupCreateDialogPO; +import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaCreateDialogPO; import com.sap.sailing.selenium.pages.common.ConfirmDialogPO; import com.sap.sailing.selenium.pages.gwt.CellTablePO; import com.sap.sailing.selenium.pages.gwt.DataEntryPO; @@ -17,7 +19,12 @@ import com.sap.sailing.selenium.pages.gwt.GenericCellTablePO; public class EventConfigurationPanelPO extends PageArea { private static final String ID_EVENT_CREATE_DIALOG = "EventCreateDialog"; + private static final String ID_REGATTA_CREATE_DIALOG = "RegattaCreateDialog"; + private static final String ID_CREATE_DEFAULT_LEADERBOARD_GROUP_DIALOG = "LeaderboardGroupCreateDialog"; private static final String ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG = "CreateDefaultLeaderboardGroupConfirmDialog"; + private static final String ID_CREATE_DEFAULT_REGATTA_CONFIRM_DIALOG = "CreateDefaultRegattaDialog"; + private static final String ID_CREATE_DEFAULT_REGATTA_LEADERBOARD_CONFIRM_DIALOG = "CreateDefaultRegattaLeaderboardDialog"; + private static final String ID_LINK_LEADERBORAD_TO_GROUP_DIALOG = "LinkRegattaLeaderboardToLeaderboardGroupOfEventDialog"; public static class EventEntryPO extends DataEntryPO { @@ -52,11 +59,17 @@ public class EventConfigurationPanelPO extends PageArea { } public void createEmptyEvent(String name, String desc, String venue, Date startDate, Date endDate, boolean isPublic) { - createEventButton.click(); - EventCreateDialogPO createDialog = getPO(EventCreateDialogPO::new, ID_EVENT_CREATE_DIALOG); - createDialog.createEvent(name, desc, venue, startDate, endDate, isPublic); - ConfirmDialogPO confirmDialog = getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG); - confirmDialog.pressNo(); + createEvent(name, desc, venue, startDate, endDate, isPublic).pressNo(); + } + + public void createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(String eventName, String eventDesc, + String venue, Date eventStartDate, Date eventEndDate, boolean isPublic, String regattaName, String boatClass, + Date regattaStartDate, Date regattaEndDate) { + createEvent(eventName, eventDesc, venue, eventStartDate, eventEndDate, isPublic).pressYes(); + getPO(LeaderboardGroupCreateDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_DIALOG).pressOk(); + getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_REGATTA_CONFIRM_DIALOG).pressYes(); + createRegatta(regattaName, boatClass, regattaStartDate, regattaEndDate).pressYes(); + getPO(ConfirmDialogPO::new, ID_LINK_LEADERBORAD_TO_GROUP_DIALOG).pressOk(); } public EventEntryPO getEventEntry(String event) { @@ -67,4 +80,19 @@ public class EventConfigurationPanelPO extends PageArea { return new GenericCellTablePO<>(this.driver, this.eventsCellTable, EventEntryPO.class); } + private ConfirmDialogPO createEvent(String name, String desc, String venue, Date start, Date end, boolean isPublic) { + createEventButton.click(); + EventCreateDialogPO createDialog = getPO(EventCreateDialogPO::new, ID_EVENT_CREATE_DIALOG); + createDialog.setValues(name, desc, venue, start, end, isPublic); + createDialog.pressOk(); + return getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG); + } + + private ConfirmDialogPO createRegatta(String name, String boatClass, Date start, Date end) { + RegattaCreateDialogPO createDialog = getPO(RegattaCreateDialogPO::new, ID_REGATTA_CREATE_DIALOG); + createDialog.setValues(name, boatClass, start, end); + createDialog.pressOk(); + return getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_REGATTA_LEADERBOARD_CONFIRM_DIALOG); + } + } From 3df6962547b6173f441d700e732c9a6f35822440 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 18:11:23 +0100 Subject: [PATCH 045/178] Fixed debug id to match elements type --- .../home/desktop/partials/regattaheader/RegattaHeaderBody.java | 2 +- .../sailing/selenium/pages/home/regatta/RegattaListItemPO.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java index 4d5b8c54215..59955828f33 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/partials/regattaheader/RegattaHeaderBody.java @@ -44,8 +44,8 @@ public class RegattaHeaderBody extends UIObject { addDetailsItem(I18N.courseAreaName(defaultCourseAreaName)); } addDetailsItem(regattaMetadata.getBoatCategory()); + UIObject.ensureDebugId(nameUi, "RegattaNameSpan"); UIObject.ensureDebugId(labelUi, "RegattaStateLabelDiv"); - UIObject.ensureDebugId(nameUi, "RegattaNameDiv"); } private void addDetailsItem(int count, String text) { diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java index 3eb080350e0..1038996f752 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java @@ -25,7 +25,7 @@ public class RegattaListItemPO extends PageArea { } public String getRegattaName() { - return findElementBySeleniumId("RegattaNameDiv").getText(); + return findElementBySeleniumId("RegattaNameSpan").getText(); } public LabelTypePO getRegattaStateLabel() { From d98930302c5c79bb319b070383308b75e271c315 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 18:13:25 +0100 Subject: [PATCH 046/178] Added convenience method to access regatta list items by regatta name --- .../sailing/selenium/pages/home/event/EventPage.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java index 4a465c53b9e..8064a8bd194 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java @@ -1,5 +1,8 @@ package com.sap.sailing.selenium.pages.home.event; +import java.text.MessageFormat; + +import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @@ -8,9 +11,12 @@ import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.pages.HostPage; import com.sap.sailing.selenium.pages.HostPageWithAuthentication; import com.sap.sailing.selenium.pages.PageObject; +import com.sap.sailing.selenium.pages.home.regatta.RegattaListItemPO; public class EventPage extends HostPageWithAuthentication { + private static final MessageFormat REGATTA_LIST_ITEM_BY_REGATTA_NAME = new MessageFormat( + ".//span[@selenium-id=\"RegattaNameSpan\" and text()=\"{0}\"]/ancestor::div[@selenium-id=\"RegattaListItemPanel\"]"); private static final String EVENT_HEADER_IDENTIFIER = "EventHeaderPanel"; /** @@ -37,5 +43,10 @@ public class EventPage extends HostPageWithAuthentication { public EventHeaderPO getEventHeader() { return getPO(EventHeaderPO::new, EVENT_HEADER_IDENTIFIER); } + + public RegattaListItemPO getRegattaListItem(String regattaName) { + String xpathExpression = REGATTA_LIST_ITEM_BY_REGATTA_NAME.format(new Object[]{regattaName}); + return new RegattaListItemPO(driver, driver.findElement(By.xpath(xpathExpression))); + } } From 30b13b968a7f2c662e41d4d5662925971a28cc9d Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 14 Mar 2016 18:14:50 +0100 Subject: [PATCH 047/178] Added test cases for upcoming and finished regattas within a live event --- .../state/TestStateVisualizationRegatta.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java new file mode 100644 index 00000000000..e833f8cb1cc --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java @@ -0,0 +1,61 @@ +package com.sap.sailing.selenium.test.integration.state; + +import static com.sap.sailing.selenium.pages.common.DateHelper.getFutureDate; +import static com.sap.sailing.selenium.pages.common.DateHelper.getPastDate; + +import java.util.Date; +import java.util.function.Predicate; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; +import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; +import com.sap.sailing.selenium.pages.common.LabelTypePO; +import com.sap.sailing.selenium.pages.home.event.EventPage; +import com.sap.sailing.selenium.pages.home.regatta.RegattaListItemPO; +import com.sap.sailing.selenium.test.AbstractSeleniumTest; + +public class TestStateVisualizationRegatta extends AbstractSeleniumTest { + + @Override + public void setUp() { + clearState(getContextRoot()); + super.setUp(); + } + + @Test + public void testStateFlagOfUpcomingRegatta() { + testStateFlagOfRegatta("TestRegatta", getFutureDate(3), getFutureDate(7), LabelTypePO::isUpcoming); + } + + // @Test + public void testStateFlagOfInProgressRegatta() { + // TODO + } + + // @Test + public void testStateFlagOfLiveRegatta() { + // TODO + } + + @Test + public void testStateFlagOfFinishedRegatta() { + testStateFlagOfRegatta("TestRegatta", getPastDate(7), getPastDate(3), LabelTypePO::isFinished); + } + + private void testStateFlagOfRegatta(String regattaName, Date regattaStartDate, Date regattaEndDate, + Predicate expectedLabelType) { + AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); + EventConfigurationPanelPO eventConfigurationPanel = adminConsolePage.goToEvents(); + final String eventName = "RegattaStateTestEvent", venue = "Anywhere", boatClass = "J-22"; + eventConfigurationPanel.createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(eventName, null, + venue, getPastDate(3), getFutureDate(3), true, regattaName, boatClass, regattaStartDate, regattaEndDate); + String eventUrl = eventConfigurationPanel.getEventEntry(eventName).getEventURL(); + EventPage eventPage = EventPage.goToEventUrl(getWebDriver(), eventUrl); + RegattaListItemPO regattaListItem = eventPage.getRegattaListItem(regattaName); + Assert.assertTrue(expectedLabelType.test(regattaListItem.getRegattaHeader().getRegattaStateLabel())); + } + +} From a0f05ea3b2624ec286a7b016968d10278f128b2f Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 11:30:04 +0100 Subject: [PATCH 048/178] Fixed debug id to to access dialog element --- .../regatta/RegattaStructureManagementPanelPO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java index 8027a05948c..82978dafb79 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java @@ -52,8 +52,8 @@ public class RegattaStructureManagementPanelPO extends PageArea { } private DefaultRegattaLeaderboardCreateDialogPO createDefaultRegattaLeaderboard() { - WebElement dialog = findElementBySeleniumId(this.driver, "CreateDefaultRegattaDialog"); //$NON-NLS-1$ - return new DefaultRegattaLeaderboardCreateDialogPO(this.driver, dialog); + WebElement dialog = findElementBySeleniumId(this.driver, "CreateDefaultRegattaLeaderboardDialog"); //$NON-NLS-1$ + return new DefaultRegattaLeaderboardCreateDialogPO(this.driver, dialog); } public RegattaListCompositePO getRegattaList() { From 12e8c535d7471ecf2f11312b0b3ffd7fb6f91cc3 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 13:08:29 +0100 Subject: [PATCH 049/178] Fixed typo in PageObject method names --- .../src/com/sap/sailing/selenium/pages/PageObject.java | 6 +++--- .../selenium/pages/authentication/AuthenticationMenuPO.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java index be84ce7fe55..923a3857fd0 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java @@ -395,13 +395,13 @@ public class PageObject { wait.until(new AjaxCallsExecuted(category, numberOfCalls)); } - protected void waitUtil(Predicate predicate) { + protected void waitUntil(Predicate predicate) { WebDriverWait webDriverWait = new WebDriverWait(driver, DEFAULT_LOOKUP_TIMEOUT); webDriverWait.until(predicate); } - protected void waitUtil(BooleanSupplier supplier) { - waitUtil((driver) -> supplier.getAsBoolean()); + protected void waitUntil(BooleanSupplier supplier) { + waitUntil((driver) -> supplier.getAsBoolean()); } /** diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java index c4b01aa068c..39a3840ba09 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/authentication/AuthenticationMenuPO.java @@ -23,12 +23,12 @@ public class AuthenticationMenuPO extends PageArea { public void doLogin(String username, String password) { AuthenticationViewPO authenticationView = showAuthenticationView(); authenticationView.getSignInView().doLogin(username, password); - waitUtil(this::isLoggedIn); + waitUntil(this::isLoggedIn); } private AuthenticationViewPO showAuthenticationView() { getWebElement().click(); - waitUtil(this::isOpen); + waitUntil(this::isOpen); return getPO(AuthenticationViewPO::new, "authenticationView"); } From 8310d29c0157d025aa50e77e9a57b9372c1623a8 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 13:34:35 +0100 Subject: [PATCH 050/178] Added convenience method to wait for element to PageObject class --- .../src/com/sap/sailing/selenium/pages/PageObject.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java index 923a3857fd0..4a1264cf030 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java @@ -11,6 +11,7 @@ import org.openqa.selenium.SearchContext; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.FluentWait; import org.openqa.selenium.support.ui.WebDriverWait; @@ -395,6 +396,11 @@ public class PageObject { wait.until(new AjaxCallsExecuted(category, numberOfCalls)); } + protected void waitForElement(String seleniumId) { + WebDriverWait webDriverWait = new WebDriverWait(driver, DEFAULT_LOOKUP_TIMEOUT); + webDriverWait.until(ExpectedConditions.presenceOfElementLocated(new BySeleniumId(seleniumId))); + } + protected void waitUntil(Predicate predicate) { WebDriverWait webDriverWait = new WebDriverWait(driver, DEFAULT_LOOKUP_TIMEOUT); webDriverWait.until(predicate); From 1360d88e3a4c291b232ec1b03c33ca8010f13a7f Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 13:35:24 +0100 Subject: [PATCH 051/178] Refactored EventPage hierarchy to a additional specific waits --- .../event/EventConfigurationPanelPO.java | 2 +- .../selenium/pages/home/event/EventPage.java | 16 ++++----- .../{regatta => event}/RegattaListItemPO.java | 2 +- .../home/event/regatta/RegattaEventPage.java | 34 +++++++++++++++++++ 4 files changed, 42 insertions(+), 12 deletions(-) rename java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/{regatta => event}/RegattaListItemPO.java (95%) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/regatta/RegattaEventPage.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java index cfc2f28888e..8db1a66d00c 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -68,7 +68,7 @@ public class EventConfigurationPanelPO extends PageArea { createEvent(eventName, eventDesc, venue, eventStartDate, eventEndDate, isPublic).pressYes(); getPO(LeaderboardGroupCreateDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_DIALOG).pressOk(); getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_REGATTA_CONFIRM_DIALOG).pressYes(); - createRegatta(regattaName, boatClass, regattaStartDate, regattaEndDate).pressYes(); + createRegatta(regattaName, boatClass, regattaStartDate, regattaEndDate).pressOk(); getPO(ConfirmDialogPO::new, ID_LINK_LEADERBORAD_TO_GROUP_DIALOG).pressOk(); } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java index 8064a8bd194..3bf55ca51a8 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/EventPage.java @@ -4,14 +4,10 @@ import java.text.MessageFormat; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.pages.HostPage; import com.sap.sailing.selenium.pages.HostPageWithAuthentication; import com.sap.sailing.selenium.pages.PageObject; -import com.sap.sailing.selenium.pages.home.regatta.RegattaListItemPO; public class EventPage extends HostPageWithAuthentication { @@ -20,24 +16,24 @@ public class EventPage extends HostPageWithAuthentication { private static final String EVENT_HEADER_IDENTIFIER = "EventHeaderPanel"; /** - * Navigates to the given home URL and provides the corresponding {@link PageObject}. + * Navigates to the given event URL and provides the corresponding {@link PageObject}. * * @param driver the {@link WebDriver} to use * @param url the desired destination URL - * @return the {@link PageObject} for the home page + * @return the {@link PageObject} for the event page */ public static EventPage goToEventUrl(WebDriver driver, String url) { return HostPage.goToUrl(EventPage::new, driver, url); } - private EventPage(WebDriver driver) { + protected EventPage(WebDriver driver) { super(driver); } @Override - protected void verify() { - WebDriverWait wait = new WebDriverWait(driver, DEFAULT_WAIT_TIMEOUT_SECONDS); - wait.until(ExpectedConditions.presenceOfElementLocated(new BySeleniumId(EVENT_HEADER_IDENTIFIER))); + protected void initElements() { + super.initElements(); + waitForElement(EVENT_HEADER_IDENTIFIER); } public EventHeaderPO getEventHeader() { diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/RegattaListItemPO.java similarity index 95% rename from java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java rename to java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/RegattaListItemPO.java index 1038996f752..8e9eb3cc67a 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/regatta/RegattaListItemPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/RegattaListItemPO.java @@ -1,4 +1,4 @@ -package com.sap.sailing.selenium.pages.home.regatta; +package com.sap.sailing.selenium.pages.home.event; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/regatta/RegattaEventPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/regatta/RegattaEventPage.java new file mode 100644 index 00000000000..f4336477f91 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/home/event/regatta/RegattaEventPage.java @@ -0,0 +1,34 @@ +package com.sap.sailing.selenium.pages.home.event.regatta; + +import org.openqa.selenium.WebDriver; + +import com.sap.sailing.selenium.pages.HostPage; +import com.sap.sailing.selenium.pages.PageObject; +import com.sap.sailing.selenium.pages.home.event.EventPage; + +public class RegattaEventPage extends EventPage { + + private static final String REGATTA_INFO_IDENTIFIER = "RegattaListItemPanel"; + + /** + * Navigates to the given regatta event URL and provides the corresponding {@link PageObject}. + * + * @param driver the {@link WebDriver} to use + * @param url the desired destination URL + * @return the {@link PageObject} for the regatta event page + */ + public static RegattaEventPage goToRegattaEventUrl(WebDriver driver, String url) { + return HostPage.goToUrl(RegattaEventPage::new, driver, url); + } + + private RegattaEventPage(WebDriver driver) { + super(driver); + } + + @Override + protected void initElements() { + super.initElements(); + waitForElement(REGATTA_INFO_IDENTIFIER); + } + +} From bb959b89a6d274cb7a716f525b161e50793e9d34 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 13:35:42 +0100 Subject: [PATCH 052/178] Adjusted test cases for upcoming and finished regattas within a live event --- .../integration/state/TestStateVisualizationRegatta.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java index e833f8cb1cc..fad7ba2cc0e 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java @@ -13,8 +13,8 @@ import org.junit.Test; import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; import com.sap.sailing.selenium.pages.common.LabelTypePO; -import com.sap.sailing.selenium.pages.home.event.EventPage; -import com.sap.sailing.selenium.pages.home.regatta.RegattaListItemPO; +import com.sap.sailing.selenium.pages.home.event.RegattaListItemPO; +import com.sap.sailing.selenium.pages.home.event.regatta.RegattaEventPage; import com.sap.sailing.selenium.test.AbstractSeleniumTest; public class TestStateVisualizationRegatta extends AbstractSeleniumTest { @@ -53,8 +53,8 @@ public class TestStateVisualizationRegatta extends AbstractSeleniumTest { eventConfigurationPanel.createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(eventName, null, venue, getPastDate(3), getFutureDate(3), true, regattaName, boatClass, regattaStartDate, regattaEndDate); String eventUrl = eventConfigurationPanel.getEventEntry(eventName).getEventURL(); - EventPage eventPage = EventPage.goToEventUrl(getWebDriver(), eventUrl); - RegattaListItemPO regattaListItem = eventPage.getRegattaListItem(regattaName); + RegattaEventPage regattaEventPage = RegattaEventPage.goToRegattaEventUrl(getWebDriver(), eventUrl); + RegattaListItemPO regattaListItem = regattaEventPage.getRegattaListItem(regattaName); Assert.assertTrue(expectedLabelType.test(regattaListItem.getRegattaHeader().getRegattaStateLabel())); } From f6583a82707fd70e3336924787c91abb092318f4 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:49:28 +0100 Subject: [PATCH 053/178] Extended BetterDateTimeBoxPO to support different time formats --- .../pages/gwt/BetterDateTimeBoxPO.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java index 8d54d61d428..6baa9dbfe0a 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/BetterDateTimeBoxPO.java @@ -14,29 +14,47 @@ import com.sap.sailing.selenium.pages.PageObject; */ public class BetterDateTimeBoxPO extends TextBoxPO { - private static final DateFormat DATE_TIME_BOX_FORMAT = new SimpleDateFormat("dd/MM/yyyy hh:mm"); + private static final DateFormat TIME_FORMAT_HOURS_MINUTES = new SimpleDateFormat("dd/MM/yyyy hh:mm"); + private static final DateFormat TIME_FORMAT_HOURS_MINUTES_SECONDS = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); + private final DateFormat timeFormat; + /** - * Factory method to create a {@link BetterDateTimeBoxPO}. + * Factory method to create a {@link BetterDateTimeBoxPO} using {@link DateFormat} dd/MM/yyyy hh:mm by + * default. * * @param driver the web driver to use * @param element the element representing the date time box on the page * @return a new {@link BetterDateTimeBoxPO} instance */ public static BetterDateTimeBoxPO create(WebDriver driver, WebElement element) { - return new BetterDateTimeBoxPO(driver, element); + return new BetterDateTimeBoxPO(driver, element, TIME_FORMAT_HOURS_MINUTES); + } + /** + * Factory method to create a {@link BetterDateTimeBoxPO}. + * + * @param driver the web driver to use + * @param element the element representing the date time box on the page + * @param includeSeconds true to use the {@link DateFormat} dd/MM/yyyy hh:mm:ss, + * false to use the default {@link DateFormat} dd/MM/yyyy hh:mm + * @return a new {@link BetterDateTimeBoxPO} instance + */ + public static BetterDateTimeBoxPO create(WebDriver driver, WebElement element, boolean includeSeconds) { + DateFormat timeFormat = includeSeconds ? TIME_FORMAT_HOURS_MINUTES_SECONDS : TIME_FORMAT_HOURS_MINUTES; + return new BetterDateTimeBoxPO(driver, element, timeFormat); } /** * @see TextBoxPO#TextBoxPO(WebDriver, WebElement) */ - protected BetterDateTimeBoxPO(WebDriver driver, WebElement element) { + protected BetterDateTimeBoxPO(WebDriver driver, WebElement element, DateFormat timeFormat) { super(driver, element); + this.timeFormat = timeFormat; } /** * Sets the underlying {@link WebElement}s text by formatting the given {@link Date} using the internal date format - * (dd/MM/yyyy hh:mm). + * (dd/MM/yyyy hh:mm or dd/MM/yyyy hh:mm:ss). * * @param date the {@link Date} object to set * @@ -44,7 +62,7 @@ public class BetterDateTimeBoxPO extends TextBoxPO { * @see #setText(String) */ public void setDate(Date date) { - this.setText(DATE_TIME_BOX_FORMAT.format(date)); + this.setText(timeFormat.format(date)); } @Override From b5721c12ab07e876fa4513fd2ffc1b0f1d098184 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:49:59 +0100 Subject: [PATCH 054/178] Extended ActionsHelper to support setting race start time --- .../sailing/selenium/pages/adminconsole/ActionsHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/ActionsHelper.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/ActionsHelper.java index 42259130534..1948e54fac6 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/ActionsHelper.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/ActionsHelper.java @@ -27,6 +27,8 @@ public class ActionsHelper { public static final String REFRESH_RACE_ACTION = "ACTION_REFRESH_RACE"; + public static final String SET_START_TIME_ACTION = "ACTION_SET_STARTTIME"; + public static WebElement findEditAction(SearchContext context) { return context.findElement(By.xpath(String.format(ACTION_XPATH, EDIT_ACTION))); } @@ -51,6 +53,10 @@ public class ActionsHelper { return context.findElement(By.xpath(String.format(ACTION_XPATH, REFRESH_RACE_ACTION))); } + public static WebElement findSetStartTimeAction(SearchContext context) { + return context.findElement(By.xpath(String.format(ACTION_XPATH, SET_START_TIME_ACTION))); + } + public static void acceptAlert(WebDriver driver) { Alert alert = getAlert(driver); alert.accept(); From c7011ecccc0f1f6d845825ad552b6bc9cb42ad2c Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:50:42 +0100 Subject: [PATCH 055/178] Added debug ids for easier access to UI elements in selenium test cases --- .../sap/sailing/gwt/ui/adminconsole/SetStartTimeDialog.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/SetStartTimeDialog.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/SetStartTimeDialog.java index 1aeada7dfa3..5635329d783 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/SetStartTimeDialog.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/SetStartTimeDialog.java @@ -59,6 +59,7 @@ public class SetStartTimeDialog extends DataEntryDialogWithBootstrap Date: Tue, 15 Mar 2016 17:51:25 +0100 Subject: [PATCH 056/178] Added page object for races table in leaderboard details panel --- .../leaderboard/LeaderboardRacesTablePO.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardRacesTablePO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardRacesTablePO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardRacesTablePO.java new file mode 100644 index 00000000000..7040166ff4c --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardRacesTablePO.java @@ -0,0 +1,40 @@ +package com.sap.sailing.selenium.pages.adminconsole.leaderboard; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.pages.adminconsole.ActionsHelper; +import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardRacesTablePO.RaceEntryPO; +import com.sap.sailing.selenium.pages.gwt.CellTablePO; +import com.sap.sailing.selenium.pages.gwt.DataEntryPO; + +public class LeaderboardRacesTablePO extends CellTablePO { + + public static class RaceEntryPO extends DataEntryPO { + + private RaceEntryPO(CellTablePO table, WebElement element) { + super(table, element); + } + + @Override + public Object getIdentifier() { + return getColumnContent("Race"); + } + + public SetStartTimeDialogPO clickSetStartTime() { + ActionsHelper.findSetStartTimeAction(getWebElement()).click(); + return getPO(SetStartTimeDialogPO::new, "SetStartTimeDialog"); + } + + } + + public LeaderboardRacesTablePO(WebDriver driver, WebElement element) { + super(driver, element); + } + + @Override + protected RaceEntryPO createDataEntry(WebElement element) { + return new RaceEntryPO(this, element); + } + +} From e5e5f2c40fabd05e952c6c33627e46f03caf1737 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:51:49 +0100 Subject: [PATCH 057/178] Added page object for races set start time dialog --- .../leaderboard/SetStartTimeDialogPO.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/SetStartTimeDialogPO.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/SetStartTimeDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/SetStartTimeDialogPO.java new file mode 100644 index 00000000000..7150af20da3 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/SetStartTimeDialogPO.java @@ -0,0 +1,38 @@ +package com.sap.sailing.selenium.pages.adminconsole.leaderboard; + +import java.util.Date; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import com.sap.sailing.selenium.core.BySeleniumId; +import com.sap.sailing.selenium.core.FindBy; +import com.sap.sailing.selenium.pages.common.DataEntryDialogPO; +import com.sap.sailing.selenium.pages.gwt.BetterDateTimeBoxPO; + +public class SetStartTimeDialogPO extends DataEntryDialogPO { + + @FindBy(how = BySeleniumId.class, using = "StartTimeTimeBox") + private WebElement startTimeTimeBox; + @FindBy(how = BySeleniumId.class, using = "AuthorNameTextBox") + private WebElement authorNameTextBox; + @FindBy(how = BySeleniumId.class, using = "AuthorPriorityIntegerBox") + private WebElement authorPriorityIntegerBox; + @FindBy(how = BySeleniumId.class, using = "RacingProcedureListBox") + private WebElement RacingProcedureListBox; + @FindBy(how = BySeleniumId.class, using = "AnvancePassIdCheckBox") + private WebElement advancePassIdCheckBox; + + public SetStartTimeDialogPO(WebDriver driver, WebElement element) { + super(driver, element); + } + + public void setStartTimeValue(Date startTime) { + BetterDateTimeBoxPO.create(driver, startTimeTimeBox, true).setDate(startTime); + } + + public void pressSetStartTime() { + this.pressOk(); + } + +} From ce6b77be8f86c95fa3270877d7a49a7ff20b8189 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:52:16 +0100 Subject: [PATCH 058/178] Adjusted LeaderboardDetailsPanelPO to provide access to races table --- .../leaderboard/LeaderboardDetailsPanelPO.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardDetailsPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardDetailsPanelPO.java index fec90980d3d..8164d7c40d3 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardDetailsPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardDetailsPanelPO.java @@ -121,7 +121,7 @@ public class LeaderboardDetailsPanelPO extends PageArea { public List getRaces() { List result = new ArrayList<>(); - CellTablePO racesTable = getRacesTable(); + LeaderboardRacesTablePO racesTable = getRacesTable(); for(DataEntryPO entry : racesTable.getEntries()) { result.add(createRaceDescriptor(entry)); } @@ -179,7 +179,7 @@ public class LeaderboardDetailsPanelPO extends PageArea { } private DataEntryPO findRace(RaceDescriptor race) { - CellTablePO racesTable = getRacesTable(); + LeaderboardRacesTablePO racesTable = getRacesTable(); for(DataEntryPO entry : racesTable.getEntries()) { RaceDescriptor descriptor = createRaceDescriptor(entry); if (descriptor.equals(race)) { @@ -206,8 +206,8 @@ public class LeaderboardDetailsPanelPO extends PageArea { return null; } - private CellTablePO getRacesTable() { - return new GenericCellTablePO<>(this.driver, this.racesCellTable, DataEntryPO.class); + public LeaderboardRacesTablePO getRacesTable() { + return new LeaderboardRacesTablePO(driver, this.racesCellTable); } private CellTablePO getTrackedRacesTable() { From 5d1d573dda91c4bb3debf202e266b4c8848976e7 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:52:36 +0100 Subject: [PATCH 059/178] Adjusted test cases for a live regatta within a live event --- .../state/TestStateVisualizationRegatta.java | 55 +++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java index fad7ba2cc0e..570c4699416 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java @@ -12,6 +12,9 @@ import org.junit.Test; import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO; +import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO; +import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardDetailsPanelPO; +import com.sap.sailing.selenium.pages.adminconsole.leaderboard.SetStartTimeDialogPO; import com.sap.sailing.selenium.pages.common.LabelTypePO; import com.sap.sailing.selenium.pages.home.event.RegattaListItemPO; import com.sap.sailing.selenium.pages.home.event.regatta.RegattaEventPage; @@ -27,7 +30,9 @@ public class TestStateVisualizationRegatta extends AbstractSeleniumTest { @Test public void testStateFlagOfUpcomingRegatta() { - testStateFlagOfRegatta("TestRegatta", getFutureDate(3), getFutureDate(7), LabelTypePO::isUpcoming); + TestCase testCase = new TestCase(); + testCase.createTestEventWithRegatta("TestRegatta", getFutureDate(3), getFutureDate(7)); + testCase.assertStateFlagOfRegatta("TestRegatta", LabelTypePO::isUpcoming); } // @Test @@ -35,27 +40,45 @@ public class TestStateVisualizationRegatta extends AbstractSeleniumTest { // TODO } - // @Test + @Test public void testStateFlagOfLiveRegatta() { - // TODO + TestCase testCase = new TestCase(); + testCase.createTestEventWithRegatta("TestLiveRegatta", getPastDate(3), getFutureDate(3)); + testCase.setLeaderboardsRaceStartTime("TestLiveRegatta", "R1", getPastDate(1)); + testCase.assertStateFlagOfRegatta("TestLiveRegatta", LabelTypePO::isLive); } @Test public void testStateFlagOfFinishedRegatta() { - testStateFlagOfRegatta("TestRegatta", getPastDate(7), getPastDate(3), LabelTypePO::isFinished); + TestCase testCase = new TestCase(); + testCase.createTestEventWithRegatta("TestRegatta", getPastDate(3), getPastDate(7)); + testCase.assertStateFlagOfRegatta("TestRegatta", LabelTypePO::isFinished); } - private void testStateFlagOfRegatta(String regattaName, Date regattaStartDate, Date regattaEndDate, - Predicate expectedLabelType) { - AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); - EventConfigurationPanelPO eventConfigurationPanel = adminConsolePage.goToEvents(); - final String eventName = "RegattaStateTestEvent", venue = "Anywhere", boatClass = "J-22"; - eventConfigurationPanel.createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(eventName, null, - venue, getPastDate(3), getFutureDate(3), true, regattaName, boatClass, regattaStartDate, regattaEndDate); - String eventUrl = eventConfigurationPanel.getEventEntry(eventName).getEventURL(); - RegattaEventPage regattaEventPage = RegattaEventPage.goToRegattaEventUrl(getWebDriver(), eventUrl); - RegattaListItemPO regattaListItem = regattaEventPage.getRegattaListItem(regattaName); - Assert.assertTrue(expectedLabelType.test(regattaListItem.getRegattaHeader().getRegattaStateLabel())); + private class TestCase { + private final AdminConsolePage adminConsolePage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot()); + private String eventUrl; + + private void createTestEventWithRegatta(String regattaName, Date regattaStartDate, Date regattaEndDate) { + EventConfigurationPanelPO eventConfigPanel = adminConsolePage.goToEvents(); + final String eventName = "RegattaStateTestEvent", venue = "Anywhere", boatClass = "J-22"; + eventConfigPanel.createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(eventName, null, venue, + getPastDate(3), getFutureDate(3), true, regattaName, boatClass, regattaStartDate, regattaEndDate); + this.eventUrl = eventConfigPanel.getEventEntry(eventName).getEventURL(); + } + + private void setLeaderboardsRaceStartTime(String leaderboard, String race, Date startTime) { + LeaderboardConfigurationPanelPO leaderboardConfiguration = adminConsolePage.goToLeaderboardConfiguration(); + LeaderboardDetailsPanelPO leaderboardDetails = leaderboardConfiguration.getLeaderboardDetails(leaderboard); + SetStartTimeDialogPO startTimeDialog = leaderboardDetails.getRacesTable().getEntry(race).clickSetStartTime(); + startTimeDialog.setStartTimeValue(startTime); + startTimeDialog.pressSetStartTime(); + } + + private void assertStateFlagOfRegatta(String regattaName, Predicate expectedLabelType) { + RegattaEventPage regattaEventPage = RegattaEventPage.goToRegattaEventUrl(getWebDriver(), eventUrl); + RegattaListItemPO regattaListItem = regattaEventPage.getRegattaListItem(regattaName); + Assert.assertTrue(expectedLabelType.test(regattaListItem.getRegattaHeader().getRegattaStateLabel())); + } } - } From b929149d334855bd7ff48061648f9e6889a3a6c3 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Mar 2016 17:57:42 +0100 Subject: [PATCH 060/178] Fixed test cases for a live regatta within a live event --- .../test/integration/state/TestStateVisualizationRegatta.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java index 570c4699416..e5d00c7462e 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java @@ -51,7 +51,7 @@ public class TestStateVisualizationRegatta extends AbstractSeleniumTest { @Test public void testStateFlagOfFinishedRegatta() { TestCase testCase = new TestCase(); - testCase.createTestEventWithRegatta("TestRegatta", getPastDate(3), getPastDate(7)); + testCase.createTestEventWithRegatta("TestRegatta", getPastDate(7), getPastDate(3)); testCase.assertStateFlagOfRegatta("TestRegatta", LabelTypePO::isFinished); } From 5c7b4e25e7eae5085e23cf57c6d0ad2b47b89f3d Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Thu, 17 Mar 2016 15:11:39 +0100 Subject: [PATCH 061/178] refactored accuracy custom view --- .../res/layout/accuracy.xml | 4 ++-- .../racecommittee/app/ui/views/AccuracyView.java | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mobile/com.sap.sailing.racecommittee.app/res/layout/accuracy.xml b/mobile/com.sap.sailing.racecommittee.app/res/layout/accuracy.xml index bb56ef5802b..02b5714d426 100644 --- a/mobile/com.sap.sailing.racecommittee.app/res/layout/accuracy.xml +++ b/mobile/com.sap.sailing.racecommittee.app/res/layout/accuracy.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/AccuracyView.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/AccuracyView.java index 65e683b0995..88b14b10900 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/AccuracyView.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/views/AccuracyView.java @@ -19,18 +19,16 @@ public class AccuracyView extends LinearLayout { private ImageView mSegment03; public AccuracyView(Context context) { - super(context); - - init(); + this(context, null); } public AccuracyView(Context context, AttributeSet attrs) { - super(context, attrs); - - init(); + this(context, attrs, 0); } - private void init() { + public AccuracyView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + inflate(getContext(), R.layout.accuracy, this); } From 14edaee717f6d1f57e10e08c879d3b934b52073c Mon Sep 17 00:00:00 2001 From: fmittag Date: Fri, 18 Mar 2016 09:01:35 +0100 Subject: [PATCH 062/178] first valid XRR from Yachtscoring. discards still missing --- .../event1390_KeyWestRaceWeek2016_xrr.xml | 6787 +++++++++-------- 1 file changed, 3394 insertions(+), 3393 deletions(-) diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml index b65da1a9214..7cdfd8d082b 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1390_KeyWestRaceWeek2016_xrr.xml @@ -1,811 +1,811 @@  - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -842,7 +842,7 @@ - + @@ -928,7 +928,7 @@ - + @@ -966,2613 +966,2614 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + From 21726ccf43f27a47751e6d566613b23057c5d3f4 Mon Sep 17 00:00:00 2001 From: fmittag Date: Fri, 18 Mar 2016 11:16:57 +0100 Subject: [PATCH 063/178] some little test adjustments --- .../resultimport/test/ParserTest.java | 12 +++---- .../ScoreCorrectionProviderImpl.java | 33 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java index 5eaa0a4c555..fbf922553ea 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java @@ -38,7 +38,7 @@ import com.sap.sse.common.impl.MillisecondsTimePoint; public class ParserTest { private static final String SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK = "event1390_KeyWestRaceWeek2016_xrr.xml"; private static final String KEYWESTRACEWEEEK_EVENT_NAME = "Key West Race Week 2016"; - private static final String ISAF_ID_29ER = "29ER"; + private static final String BOAT_CLASS_J111 = "J 111"; private static final String RESOURCES = "resources/"; @@ -57,9 +57,9 @@ public class ParserTest { try { List result = new ArrayList(); - Date _29erDate = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); + Date _J111Date = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK), - null, new MillisecondsTimePoint(_29erDate), KEYWESTRACEWEEEK_EVENT_NAME , null, ISAF_ID_29ER)); + null, new MillisecondsTimePoint(_J111Date), KEYWESTRACEWEEEK_EVENT_NAME , null, BOAT_CLASS_J111)); return result; } catch (Exception e) { @@ -85,10 +85,10 @@ public class ParserTest { getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); - Set> resultsForYES = hasResultsFor.get(KEYWESTRACEWEEEK_EVENT_NAME); - assertNotNull(resultsForYES); + Set> resultsForKeyWestRaceWeek = hasResultsFor.get(KEYWESTRACEWEEEK_EVENT_NAME); + assertNotNull(resultsForKeyWestRaceWeek); - assertEquals(3, resultsForYES.size()); + assertEquals(3, resultsForKeyWestRaceWeek.size()); } // @Test diff --git a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java index 0759eadcca1..73353e3afdc 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java +++ b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java @@ -87,27 +87,26 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res Parser parser = resolveParser(eventName, boatClassName); try { RegattaResults regattaResults = parser.parse(); - for (Object o : regattaResults.getPersonOrBoatOrTeam()) { - if (o instanceof Event) { - Event event = (Event) o; - if (event.getTitle().equals(eventName)) { - for (Object eventO : event.getRaceOrDivisionOrRegattaSeriesResult()) { - if (eventO instanceof Division) { - Division division = (Division) eventO; - EventGender divisionGender = division.getGender(); - String divisionBoatClassAndGender = parser.getBoatClassName(division); - if(divisionGender != null) { - divisionBoatClassAndGender += ", " + divisionGender.name(); - } - if (boatClassName.equalsIgnoreCase(divisionBoatClassAndGender) || boatClassName.contains(divisionBoatClassAndGender)) { - return new XRRRegattaResultsAsScoreCorrections(event, division, this, - parser); - } + for (Object o : regattaResults.getPersonOrBoatOrTeam()) { + if (o instanceof Event) { + Event event = (Event) o; + if (event.getTitle().equals(eventName)) { + for (Object eventO : event.getRaceOrDivisionOrRegattaSeriesResult()) { + if (eventO instanceof Division) { + Division division = (Division) eventO; + EventGender divisionGender = division.getGender(); + String divisionBoatClassAndGender = parser.getBoatClassName(division); + if(divisionGender != null) { + divisionBoatClassAndGender += ", " + divisionGender.name(); + } + if (boatClassName.equalsIgnoreCase(divisionBoatClassAndGender) || boatClassName.contains(divisionBoatClassAndGender)) { + return new XRRRegattaResultsAsScoreCorrections(event, division, this, + parser); } } } } -// } + } } } catch (JAXBException e) { logger.info("Parse error during XRR import. Ignoring document " + parser.toString()); From a2c8b802a4a5df5ea0aead204a6567badd0ef338 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 21 Mar 2016 14:57:58 +0100 Subject: [PATCH 064/178] Fixed typo in label type or in progress labels --- .../src/com/sap/sailing/selenium/pages/common/LabelTypePO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java index 1b165983b91..4f7a012db73 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/LabelTypePO.java @@ -9,7 +9,7 @@ public class LabelTypePO extends PageArea { private static final String LABEL_TYPE_LIVE = "live"; private static final String LABEL_TYPE_FINISHED = "finished"; - private static final String LABEL_TYPE_INPROGRESS = "proress"; + private static final String LABEL_TYPE_INPROGRESS = "progress"; private static final String LABEL_TYPE_UPCOMING = "upcoming"; public LabelTypePO(WebDriver driver, WebElement element) { From f3743118117eaac38e08d834f1fee8510d265e18 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 21 Mar 2016 15:00:03 +0100 Subject: [PATCH 065/178] Extended DateHelper to create dates x minutes in the past/future --- .../selenium/pages/common/DateHelper.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java index 73af230dc09..77fbef7dd5f 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DateHelper.java @@ -7,21 +7,29 @@ import java.util.GregorianCalendar; public class DateHelper { public static Date getPastDate(int daysInPast) { - return getOffsetDate(-daysInPast); + return getOffsetDate(-daysInPast, Calendar.DATE); + } + + public static Date getPastTime(int minutesInPast) { + return getOffsetDate(-minutesInPast, Calendar.MINUTE); } public static Date getCurrentDate() { - return getOffsetDate(0); + return getOffsetDate(0, Calendar.MILLISECOND); } public static Date getFutureDate(int daysInFuture) { - return getOffsetDate(daysInFuture); + return getOffsetDate(daysInFuture, Calendar.DATE); } - private static Date getOffsetDate(int offsetInDays) { + public static Date getFutureTime(int minutesInFuture) { + return getOffsetDate(minutesInFuture, Calendar.MINUTE); + } + + private static Date getOffsetDate(int offset, int calendarFieldNumber) { Calendar calendar = GregorianCalendar.getInstance(); - calendar.add(Calendar.DATE, offsetInDays); + calendar.add(calendarFieldNumber, offset); return calendar.getTime(); } - + } From a0daf681511dc0f5e1d9aa08d14da13659c14057 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 21 Mar 2016 17:01:14 +0100 Subject: [PATCH 066/178] Added convenience class for sending RaceLogRaceStatusEvents to server --- .../pages/common/RaceStatusEventHelper.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/RaceStatusEventHelper.java diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/RaceStatusEventHelper.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/RaceStatusEventHelper.java new file mode 100644 index 00000000000..f7a6706c70f --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/RaceStatusEventHelper.java @@ -0,0 +1,67 @@ +package com.sap.sailing.selenium.pages.common; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.MessageFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.json.JSONArray; +import org.json.JSONObject; + +import com.sap.sailing.domain.common.racelog.RaceLogServletConstants; +import com.sap.sse.common.Base64Utils; + +public class RaceStatusEventHelper { + + private static final MessageFormat RACE_LOG_URL = new MessageFormat("{0}sailingserver/rc/racelog?" + + RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "={1}&" + RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + + "={2}&" + RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "={3}"); + + public static RaceStatusEventHelper get(String contextRoot, String leaderboard, String raceColumn, String fleet) { + return new RaceStatusEventHelper(contextRoot, leaderboard, raceColumn, fleet); + } + + private final String raceLogUrl; + + private RaceStatusEventHelper(Object... parameters) { + this.raceLogUrl = RACE_LOG_URL.format(parameters); + } + + public void finishRace(Date finishDate) { + sendRaceLogRaceStatusEvent(finishDate, finishDate, "FINISHED"); + } + + private void sendRaceLogRaceStatusEvent(Date timestamp, Date createdAt, String nextStatus) { + Map jsonParams = new HashMap<>(); + jsonParams.put("@class", "RaceLogRaceStatusEvent"); + jsonParams.put("timestamp", timestamp.getTime()); + jsonParams.put("createdAt", createdAt.getTime()); + jsonParams.put("nextStatus", nextStatus); + jsonParams.put("competitors", new JSONArray()); + jsonParams.put("passId", 0); + jsonParams.put("id", UUID.randomUUID()); + sendRaceLogEvent(jsonParams); + } + + private void sendRaceLogEvent(Map jsonParams) { + try { + HttpURLConnection connection = (HttpURLConnection) new URL(raceLogUrl).openConnection(); + connection.setInstanceFollowRedirects(false); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Authorization", "Basic " + Base64Utils.toBase64("admin:admin".getBytes())); + connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + connection.setDoOutput(true); + connection.connect(); + connection.getOutputStream().write(new JSONObject(jsonParams).toString().getBytes()); + int responseCode = connection.getResponseCode(); + if (responseCode != 200) throw new RuntimeException(responseCode + " " + connection.getResponseMessage()); + } catch (IOException exception) { + throw new RuntimeException(exception); + } + } + +} From 9c8a4bd01ee1d4bfcb08d3348ab531e9b5d8f152 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Mon, 21 Mar 2016 17:12:33 +0100 Subject: [PATCH 067/178] Added test cases for an in progress regatta within a live event --- .../state/TestStateVisualizationRegatta.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java index e5d00c7462e..f3c94f3cf9d 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/integration/state/TestStateVisualizationRegatta.java @@ -2,12 +2,14 @@ package com.sap.sailing.selenium.test.integration.state; import static com.sap.sailing.selenium.pages.common.DateHelper.getFutureDate; import static com.sap.sailing.selenium.pages.common.DateHelper.getPastDate; +import static com.sap.sailing.selenium.pages.common.DateHelper.getPastTime; import java.util.Date; import java.util.function.Predicate; import junit.framework.Assert; +import org.junit.Before; import org.junit.Test; import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage; @@ -16,6 +18,7 @@ import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfig import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardDetailsPanelPO; import com.sap.sailing.selenium.pages.adminconsole.leaderboard.SetStartTimeDialogPO; import com.sap.sailing.selenium.pages.common.LabelTypePO; +import com.sap.sailing.selenium.pages.common.RaceStatusEventHelper; import com.sap.sailing.selenium.pages.home.event.RegattaListItemPO; import com.sap.sailing.selenium.pages.home.event.regatta.RegattaEventPage; import com.sap.sailing.selenium.test.AbstractSeleniumTest; @@ -23,6 +26,7 @@ import com.sap.sailing.selenium.test.AbstractSeleniumTest; public class TestStateVisualizationRegatta extends AbstractSeleniumTest { @Override + @Before public void setUp() { clearState(getContextRoot()); super.setUp(); @@ -31,28 +35,32 @@ public class TestStateVisualizationRegatta extends AbstractSeleniumTest { @Test public void testStateFlagOfUpcomingRegatta() { TestCase testCase = new TestCase(); - testCase.createTestEventWithRegatta("TestRegatta", getFutureDate(3), getFutureDate(7)); - testCase.assertStateFlagOfRegatta("TestRegatta", LabelTypePO::isUpcoming); + testCase.createTestEventWithRegatta("TestUpcomingRegatta", getFutureDate(3), getFutureDate(7)); + testCase.assertStateFlagOfRegatta("TestUpcomingRegatta", LabelTypePO::isUpcoming); } - // @Test + @Test public void testStateFlagOfInProgressRegatta() { - // TODO + TestCase testCase = new TestCase(); + testCase.createTestEventWithRegatta("TestInProgressRegatta", getPastDate(3), getFutureDate(3)); + testCase.setLeaderboardsRaceStartTime("TestInProgressRegatta", "R1", getPastTime(20)); + RaceStatusEventHelper.get(getContextRoot(),"TestInProgressRegatta", "R1", "Default").finishRace(getPastTime(5)); + testCase.assertStateFlagOfRegatta("TestInProgressRegatta", LabelTypePO::isInProgress); } @Test public void testStateFlagOfLiveRegatta() { TestCase testCase = new TestCase(); testCase.createTestEventWithRegatta("TestLiveRegatta", getPastDate(3), getFutureDate(3)); - testCase.setLeaderboardsRaceStartTime("TestLiveRegatta", "R1", getPastDate(1)); + testCase.setLeaderboardsRaceStartTime("TestLiveRegatta", "R1", getPastTime(30)); testCase.assertStateFlagOfRegatta("TestLiveRegatta", LabelTypePO::isLive); } @Test public void testStateFlagOfFinishedRegatta() { TestCase testCase = new TestCase(); - testCase.createTestEventWithRegatta("TestRegatta", getPastDate(7), getPastDate(3)); - testCase.assertStateFlagOfRegatta("TestRegatta", LabelTypePO::isFinished); + testCase.createTestEventWithRegatta("TestFinishedRegatta", getPastDate(7), getPastDate(3)); + testCase.assertStateFlagOfRegatta("TestFinishedRegatta", LabelTypePO::isFinished); } private class TestCase { From 6b135f7978b5648cd6a99f9a33e1276976a5b728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bro=C3=9F?= Date: Mon, 21 Mar 2016 17:13:16 +0100 Subject: [PATCH 068/178] Move updateStartAndEndOfTracking to TrackedRaceImpl and set up some more handlers in DynamicTrackedRaceLogListener --- .../impl/RaceLogRaceTracker.java | 50 +------- .../domain/test/mock/MockedTrackedRace.java | 8 ++ ...ockedTrackedRaceWithStartTimeAndRanks.java | 4 + .../domain/tracking/DynamicTrackedRace.java | 1 + .../sailing/domain/tracking/TrackedRace.java | 15 +++ .../tracking/impl/DynamicTrackedRaceImpl.java | 8 +- .../impl/DynamicTrackedRaceLogListener.java | 17 +++ .../domain/tracking/impl/TrackedRaceImpl.java | 109 ++++++++++++++++++ .../gwt/ui/test/MockedTrackedRace.java | 8 ++ .../server/masterdata/DummyTrackedRace.java | 4 + 10 files changed, 175 insertions(+), 49 deletions(-) diff --git a/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/RaceLogRaceTracker.java b/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/RaceLogRaceTracker.java index 4a97ac5a46b..7a619ea19e3 100755 --- a/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/RaceLogRaceTracker.java +++ b/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/RaceLogRaceTracker.java @@ -75,9 +75,7 @@ import com.sap.sailing.domain.tracking.impl.TrackedRaceStatusImpl; import com.sap.sse.common.NoCorrespondingServiceRegisteredException; import com.sap.sse.common.TimePoint; import com.sap.sse.common.Util; -import com.sap.sse.common.Util.Pair; import com.sap.sse.common.WithID; -import com.sap.sse.common.impl.MillisecondsTimePoint; import difflib.PatchFailedException; @@ -239,50 +237,6 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener { return new RegattaLogDeviceMarkMappingFinder(params.getRegattaLog()).analyze(); } - /** - * Use mapping time ranges to set time start and end of tracking time for race - */ - private void updateStartAndEndOfTracking() { - // TODO bug 3196: this would need to be evaluated lazily in TrackedRaceImpl.getStartOfTracking / getEndOfTracking - final Pair trackingTimesFromRaceLog = trackedRace.getTrackingTimesFromRaceLogs(); - if (trackingTimesFromRaceLog == null) { - TimePoint earliestMappingStart = new MillisecondsTimePoint(Long.MAX_VALUE); - TimePoint latestMappingEnd = new MillisecondsTimePoint(Long.MIN_VALUE); - for (List> list : competitorMappings.values()) { - for (DeviceMapping mapping : list) { - earliestMappingStart = getUpdatedEarliestMappingStart(earliestMappingStart, mapping.getTimeRange().from()); - latestMappingEnd = getUpdatedLatestMappingEnd(latestMappingEnd, mapping.getTimeRange().to()); - } - } - for (List> list : markMappings.values()) { - for (DeviceMapping mapping : list) { - earliestMappingStart = getUpdatedEarliestMappingStart(earliestMappingStart, mapping.getTimeRange().from()); - latestMappingEnd = getUpdatedLatestMappingEnd(latestMappingEnd, mapping.getTimeRange().to()); - } - } - trackedRace.setStartOfTrackingReceived(earliestMappingStart == null ? TimePoint.BeginningOfTime : earliestMappingStart); - trackedRace.setEndOfTrackingReceived(latestMappingEnd == null ? TimePoint.EndOfTime : latestMappingEnd); - } - } - - private TimePoint getUpdatedEarliestMappingStart(TimePoint earliestMappingStart, final TimePoint from) { - if (from == null) { - earliestMappingStart = null; // no further updates; one open interval means startOfTracking shall be the beginning of time - } else if (earliestMappingStart != null && from.before(earliestMappingStart)) { - earliestMappingStart = from; - } - return earliestMappingStart; - } - - private TimePoint getUpdatedLatestMappingEnd(TimePoint latestMappingEnd, final TimePoint to) { - if (to == null) { - latestMappingEnd = null; // no further updates; one open interval means startOfTracking shall be the beginning of time - } else if (latestMappingEnd != null && to.after(latestMappingEnd)) { - latestMappingEnd = to; - } - return latestMappingEnd; - } - private boolean hasMappingAlreadyBeenLoaded( DeviceMapping newMapping, List> oldMappings) { if (oldMappings == null) { @@ -355,7 +309,7 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener { markMappingsByDevices.clear(); markMappingsByDevices.putAll(transformToMappingsByDevice(markMappings)); - updateStartAndEndOfTracking(); + trackedRace.updateStartAndEndOfTracking(); } private void onDeviceMarkMappingEvent(RegattaLogDeviceMarkMappingEvent event) { @@ -429,7 +383,7 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener { competitorMappings.putAll(newMappings); competitorMappingsByDevices.clear(); competitorMappingsByDevices.putAll(transformToMappingsByDevice(competitorMappings)); - updateStartAndEndOfTracking(); + trackedRace.updateStartAndEndOfTracking(); } private void onStartTrackingEvent(RaceLogStartTrackingEvent event) { diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRace.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRace.java index 9b361a08525..de2a29faa94 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRace.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRace.java @@ -1029,4 +1029,12 @@ public class MockedTrackedRace implements DynamicTrackedRace { @Override public void updateMarkPassingsAfterRaceLogChanges() { } + + @Override + public void updateStartAndEndOfTracking() { + } + + @Override + public void onFinishedTimeChangedByRaceCommittee(TimePoint newFinishedTime) { + } } diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRaceWithStartTimeAndRanks.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRaceWithStartTimeAndRanks.java index 95715cebb2c..eb16408e1d3 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRaceWithStartTimeAndRanks.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRaceWithStartTimeAndRanks.java @@ -649,4 +649,8 @@ public class MockedTrackedRaceWithStartTimeAndRanks implements TrackedRace { public IsManagedByCache resolve(SharedDomainFactory domainFactory) { return this; } + + @Override + public void updateStartAndEndOfTracking() { + } } diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/DynamicTrackedRace.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/DynamicTrackedRace.java index 3c4177fce24..f7159f12c42 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/DynamicTrackedRace.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/DynamicTrackedRace.java @@ -128,6 +128,7 @@ public interface DynamicTrackedRace extends TrackedRace { void onCourseDesignChangedByRaceCommittee(CourseBase courseDesign); void onStartTimeChangedByRaceCommittee(TimePoint newStartTime); + void onFinishedTimeChangedByRaceCommittee(TimePoint newFinishedTime); void onAbortedByRaceCommittee(Flags flag); diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedRace.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedRace.java index 94fde1cf210..f8383086ef8 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedRace.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedRace.java @@ -865,6 +865,10 @@ public interface TrackedRace extends Serializable, IsManagedByCache getTrackingTimesFromRaceLogs() { return null; } + + default Pair getStartAndFinishedTimeFromRaceLogs() { + return null; + } /** * Returns all marks found in the {@link #markTracks} map and the mark device mappings and mark @@ -875,4 +879,15 @@ public interface TrackedRace extends Serializable, IsManagedByCache getMarksFromRegattaLogs() { return getMarks(); } + + /** + * Forces update of start and end of tracking. + * Adheres to the following precedence order + * + * 1) RaceLogStartOfTrackingEvent/RaceLogEndOfTrackingEvent + * 2) RaceLogStartTimeEvent - x Minutes, Race finished + x Minutes + * 3) Earliest Mapping, Latest Mapping (of Marks and Competitors) + * 4) Leave previously (manually set start/end of tracking) + */ + public void updateStartAndEndOfTracking(); } diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceImpl.java index c6b2997f97c..25ac24e8a64 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceImpl.java @@ -978,6 +978,13 @@ DynamicTrackedRace, GPSTrackListener { } catch (IOException e) { logger.log(Level.INFO, "Exception trying to notify race status change listeners about start time change", e); } + updateStartAndEndOfTracking(); + } + + @Override + public void onFinishedTimeChangedByRaceCommittee(TimePoint newFinishedTime) { + logger.info("Finished time of race "+getRace().getName()+" updated by race committee to "+newFinishedTime); + updateStartAndEndOfTracking(); } @Override @@ -1010,5 +1017,4 @@ DynamicTrackedRace, GPSTrackListener { public DynamicGPSFixTrack getTrack(Mark mark) { return (DynamicGPSFixTrack) super.getTrack(mark); } - } diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java index 2c27235f626..20a970cba88 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java @@ -13,6 +13,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogFinishPositioningConfirmed import com.sap.sailing.domain.abstractlog.race.RaceLogFixedMarkPassingEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogFlagEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogPassChangeEvent; +import com.sap.sailing.domain.abstractlog.race.RaceLogRaceStatusEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogStartOfTrackingEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent; @@ -31,6 +32,7 @@ import com.sap.sailing.domain.common.Wind; import com.sap.sailing.domain.common.WindSource; import com.sap.sailing.domain.common.WindSourceType; import com.sap.sailing.domain.common.impl.WindSourceImpl; +import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus; import com.sap.sailing.domain.markpassingcalculation.MarkPassingUpdateListener; import com.sap.sailing.domain.tracking.DynamicTrackedRace; import com.sap.sailing.domain.tracking.RaceLogWindFixDeclinationHelper; @@ -309,6 +311,14 @@ public class DynamicTrackedRaceLogListener extends BaseRaceLogEventVisitor { markPassingUpdateListener.removeFixedPassing(revokedEvent.getInvolvedBoats().get(0), ((RaceLogFixedMarkPassingEvent) revokedEvent).getZeroBasedIndexOfPassedWaypoint()); } + if (revokedEvent instanceof RaceLogDependentStartTimeEvent || revokedEvent instanceof RaceLogStartTimeEvent){ + analyzeStartTime(null); + } + if (revokedEvent instanceof RaceLogRaceStatusEvent){ + if (((RaceLogRaceStatusEvent) revokedEvent).getNextStatus().equals(RaceLogRaceStatus.FINISHED)){ + trackedRace.invalidateEndTime(); + } + } } } @@ -326,4 +336,11 @@ public class DynamicTrackedRaceLogListener extends BaseRaceLogEventVisitor { public void visit(RaceLogEndOfTrackingEvent event) { trackedRace.setEndOfTrackingReceived(event.getLogicalTimePoint()); } + + @Override + public void visit(RaceLogRaceStatusEvent event) { + if (event.getNextStatus().equals(RaceLogRaceStatus.FINISHED)){ + trackedRace.invalidateEndTime(); + } + } } diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java index 135ca76e571..bf7d47fb01e 100644 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java @@ -40,6 +40,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogGateLineOpeningTimeEvent; import com.sap.sailing.domain.abstractlog.race.RaceLogStartOfTrackingEvent; import com.sap.sailing.domain.abstractlog.race.SimpleRaceLogIdentifier; +import com.sap.sailing.domain.abstractlog.race.analyzing.impl.FinishedTimeFinder; import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogResolver; import com.sap.sailing.domain.abstractlog.race.analyzing.impl.StartTimeFinder; import com.sap.sailing.domain.abstractlog.race.analyzing.impl.TrackingTimesFinder; @@ -49,6 +50,8 @@ import com.sap.sailing.domain.abstractlog.race.state.impl.RaceStateImpl; import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.ReadonlyRacingProcedure; import com.sap.sailing.domain.abstractlog.regatta.RegattaLog; import com.sap.sailing.domain.abstractlog.regatta.tracking.analyzing.impl.RegattaLogDefinedMarkAnalyzer; +import com.sap.sailing.domain.abstractlog.regatta.tracking.analyzing.impl.RegattaLogDeviceCompetitorMappingFinder; +import com.sap.sailing.domain.abstractlog.regatta.tracking.analyzing.impl.RegattaLogDeviceMarkMappingFinder; import com.sap.sailing.domain.base.BoatClass; import com.sap.sailing.domain.base.Competitor; import com.sap.sailing.domain.base.Course; @@ -111,6 +114,7 @@ import com.sap.sailing.domain.polars.NotEnoughDataHasBeenAddedException; import com.sap.sailing.domain.polars.PolarDataService; import com.sap.sailing.domain.racelog.tracking.EmptyGPSFixStore; import com.sap.sailing.domain.racelog.tracking.GPSFixStore; +import com.sap.sailing.domain.racelogtracking.DeviceMapping; import com.sap.sailing.domain.ranking.OneDesignRankingMetric; import com.sap.sailing.domain.ranking.RankingMetric; import com.sap.sailing.domain.ranking.RankingMetric.RankingInfo; @@ -156,6 +160,8 @@ import difflib.Patch; import difflib.PatchFailedException; public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials implements CourseListener { + private static final int TRACKING_BUFFER_IN_MINUTES = 5; + private static final long serialVersionUID = -4825546964220003507L; private static final Logger logger = Logger.getLogger(TrackedRaceImpl.class.getName()); @@ -722,11 +728,100 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl @Override public TimePoint getStartOfTracking() { + updateStartAndEndOfTracking();//FIXME: unclear whether change listeners etc similar to DynamicTrackedRace can be used here for caching and invalidation return startOfTrackingReceived; } + + /** + * Use mapping time ranges to set time start and end of tracking time for race + */ + public void updateStartAndEndOfTracking() { + final Pair trackingTimesFromRaceLog = this.getTrackingTimesFromRaceLogs(); + final Pair startAndFinishedTimesFromRaceLog = this.getStartAndFinishedTimeFromRaceLogs(); + + boolean startOfTrackingFound = false; + boolean endOfTrackingFound = false; + + if (trackingTimesFromRaceLog != null){ + if (trackingTimesFromRaceLog.getA() != null){ + setStartOfTrackingReceived(trackingTimesFromRaceLog.getA(), false); + startOfTrackingFound = true; + } + if (trackingTimesFromRaceLog.getB() != null){ + setEndOfTrackingReceived(trackingTimesFromRaceLog.getB(), false); + endOfTrackingFound = true; + } + } + + if(!startOfTrackingFound || !endOfTrackingFound){ + if (startAndFinishedTimesFromRaceLog != null){ + if (!startOfTrackingFound && startAndFinishedTimesFromRaceLog.getA() != null){ + setStartOfTrackingReceived(startAndFinishedTimesFromRaceLog.getA().minus(Duration.ONE_MINUTE.times(TRACKING_BUFFER_IN_MINUTES)), false); + startOfTrackingFound = true; + } + if (!endOfTrackingFound && startAndFinishedTimesFromRaceLog.getB() != null){ + setEndOfTrackingReceived(startAndFinishedTimesFromRaceLog.getB().plus(Duration.ONE_MINUTE.times(TRACKING_BUFFER_IN_MINUTES)), false); + endOfTrackingFound = true; + } + } + } + + if(!startOfTrackingFound || !endOfTrackingFound){ + TimePoint earliestMappingStart = new MillisecondsTimePoint(Long.MAX_VALUE); + TimePoint latestMappingEnd = new MillisecondsTimePoint(Long.MIN_VALUE); + Map>> markMappings = new HashMap>>(); + Map>> competitorMappings = new HashMap>>(); + for (RegattaLog regattaLog: attachedRegattaLogs.values()){ + competitorMappings.putAll(new RegattaLogDeviceCompetitorMappingFinder(regattaLog).analyze()); + markMappings.putAll(new RegattaLogDeviceMarkMappingFinder(regattaLog).analyze()); + } + for (List> list : competitorMappings.values()) { + for (DeviceMapping mapping : list) { + earliestMappingStart = getUpdatedEarliestMappingStart(earliestMappingStart, mapping.getTimeRange().from()); + latestMappingEnd = getUpdatedLatestMappingEnd(latestMappingEnd, mapping.getTimeRange().to()); + } + } + for (List> list : markMappings.values()) { + for (DeviceMapping mapping : list) { + earliestMappingStart = getUpdatedEarliestMappingStart(earliestMappingStart, mapping.getTimeRange().from()); + latestMappingEnd = getUpdatedLatestMappingEnd(latestMappingEnd, mapping.getTimeRange().to()); + } + } + + if (!startOfTrackingFound && earliestMappingStart != null){ + setStartOfTrackingReceived(earliestMappingStart, false); + } + + if (!endOfTrackingFound && latestMappingEnd != null){ + setEndOfTrackingReceived(latestMappingEnd, false); + } + } + } + + private TimePoint getUpdatedEarliestMappingStart(TimePoint earliestMappingStart, final TimePoint from) { + if (from == null) { + earliestMappingStart = null; // no further updates; one open interval means startOfTracking shall be the beginning of time + } else if (earliestMappingStart != null && from.before(earliestMappingStart)) { + earliestMappingStart = from; + } + return earliestMappingStart; + } + + private TimePoint getUpdatedLatestMappingEnd(TimePoint latestMappingEnd, final TimePoint to) { + if (to == null) { + latestMappingEnd = null; // no further updates; one open interval means startOfTracking shall be the beginning of time + } else if (latestMappingEnd != null && to.after(latestMappingEnd)) { + latestMappingEnd = to; + } + return latestMappingEnd; + } + + + @Override public TimePoint getEndOfTracking() { + updateStartAndEndOfTracking();//FIXME: unclear whether change listeners etc similar to DynamicTrackedRace can be used here for caching and invalidation return endOfTrackingReceived; } @@ -762,6 +857,20 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl } return null; } + + @Override + public Pair getStartAndFinishedTimeFromRaceLogs() { + //Only one of the RaceLogs should have valid data, so one doesn't have to compare all the + //start/finished time values in order to find the earliest startTime/latestFinishedTime + for (final RaceLog raceLog : attachedRaceLogs.values()) { + TimePoint startTime = new StartTimeFinder(raceLogResolver, raceLog).analyze().getStartTime(); + TimePoint finishedTime = new FinishedTimeFinder(raceLog).analyze(); + if (startTime != null || finishedTime != null){ + return new Util.Pair(startTime, finishedTime); + } + } + return null; + } /** * Calculates the start time of the race from various sources. The highest precedence take the {@link #attachedRaceLogs race logs}, diff --git a/java/com.sap.sailing.gwt.ui.test/src/com/sap/sailing/gwt/ui/test/MockedTrackedRace.java b/java/com.sap.sailing.gwt.ui.test/src/com/sap/sailing/gwt/ui/test/MockedTrackedRace.java index d35c075b9f6..c6d813eb2a2 100755 --- a/java/com.sap.sailing.gwt.ui.test/src/com/sap/sailing/gwt/ui/test/MockedTrackedRace.java +++ b/java/com.sap.sailing.gwt.ui.test/src/com/sap/sailing/gwt/ui/test/MockedTrackedRace.java @@ -790,4 +790,12 @@ public class MockedTrackedRace implements DynamicTrackedRace { @Override public void updateMarkPassingsAfterRaceLogChanges() { } + + @Override + public void updateStartAndEndOfTracking() { + } + + @Override + public void onFinishedTimeChangedByRaceCommittee(TimePoint newFinishedTime) { + } } diff --git a/java/com.sap.sailing.server/src/com/sap/sailing/server/masterdata/DummyTrackedRace.java b/java/com.sap.sailing.server/src/com/sap/sailing/server/masterdata/DummyTrackedRace.java index 23b95da6c7e..e7b476f6081 100755 --- a/java/com.sap.sailing.server/src/com/sap/sailing/server/masterdata/DummyTrackedRace.java +++ b/java/com.sap.sailing.server/src/com/sap/sailing/server/masterdata/DummyTrackedRace.java @@ -624,4 +624,8 @@ public class DummyTrackedRace extends TrackedRaceWithWindEssentials { public IsManagedByCache resolve(SharedDomainFactory domainFactory) { return this; } + + @Override + public void updateStartAndEndOfTracking() { + } } From 297b85f30feca02241de6b2fc4c7b022b367aa6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bro=C3=9F?= Date: Mon, 21 Mar 2016 17:35:21 +0100 Subject: [PATCH 069/178] Removes unused methods as RaceLogRaceStatusEvent not revocabke --- .../tracking/impl/DynamicTrackedRaceLogListener.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java index 20a970cba88..ceb97a8ea17 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/DynamicTrackedRaceLogListener.java @@ -311,14 +311,6 @@ public class DynamicTrackedRaceLogListener extends BaseRaceLogEventVisitor { markPassingUpdateListener.removeFixedPassing(revokedEvent.getInvolvedBoats().get(0), ((RaceLogFixedMarkPassingEvent) revokedEvent).getZeroBasedIndexOfPassedWaypoint()); } - if (revokedEvent instanceof RaceLogDependentStartTimeEvent || revokedEvent instanceof RaceLogStartTimeEvent){ - analyzeStartTime(null); - } - if (revokedEvent instanceof RaceLogRaceStatusEvent){ - if (((RaceLogRaceStatusEvent) revokedEvent).getNextStatus().equals(RaceLogRaceStatus.FINISHED)){ - trackedRace.invalidateEndTime(); - } - } } } From 9193f6c6ade1014649c7fab2e57910d7b3aab032 Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Wed, 23 Mar 2016 12:26:27 +0100 Subject: [PATCH 070/178] increased "running time" area size on phones (because of the update badge) --- mobile/com.sap.sailing.racecommittee.app/res/values/dimens.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/com.sap.sailing.racecommittee.app/res/values/dimens.xml b/mobile/com.sap.sailing.racecommittee.app/res/values/dimens.xml index 9a25e9ac2cc..ec938467dab 100644 --- a/mobile/com.sap.sailing.racecommittee.app/res/values/dimens.xml +++ b/mobile/com.sap.sailing.racecommittee.app/res/values/dimens.xml @@ -4,7 +4,7 @@ 80dp 120dp 320dp - 120dp + 150dp 12dp 80dp From 76b4ad41cb8ab60f0df646f83bb3c812b838e8a4 Mon Sep 17 00:00:00 2001 From: fmittag Date: Wed, 23 Mar 2016 19:14:17 +0100 Subject: [PATCH 071/178] first working version of yachtscoring importer... still bugs in the XRR file from yachtscoring --- .../UrlBasedXRRResultDocumentProvider.java | 57 + .../event1220_CharlstonRaceWeek2015_xrr.xml | 4769 +++++++++++++++++ .../CharlstonRaceWeek2015_ParserTest.java | 125 + ...va => KeyWestRaceWeek2016_ParserTest.java} | 73 +- .../ScoreCorrectionProviderImpl.java | 10 +- .../YachtscoringResultDocumentProvider.java | 72 +- 6 files changed, 5032 insertions(+), 74 deletions(-) create mode 100644 java/com.sap.sailing.xrr.resultimport/src/com/sap/sailing/xrr/resultimport/impl/UrlBasedXRRResultDocumentProvider.java create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1220_CharlstonRaceWeek2015_xrr.xml create mode 100644 java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/CharlstonRaceWeek2015_ParserTest.java rename java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/{ParserTest.java => KeyWestRaceWeek2016_ParserTest.java} (53%) diff --git a/java/com.sap.sailing.xrr.resultimport/src/com/sap/sailing/xrr/resultimport/impl/UrlBasedXRRResultDocumentProvider.java b/java/com.sap.sailing.xrr.resultimport/src/com/sap/sailing/xrr/resultimport/impl/UrlBasedXRRResultDocumentProvider.java new file mode 100644 index 00000000000..dd75457c147 --- /dev/null +++ b/java/com.sap.sailing.xrr.resultimport/src/com/sap/sailing/xrr/resultimport/impl/UrlBasedXRRResultDocumentProvider.java @@ -0,0 +1,57 @@ +package com.sap.sailing.xrr.resultimport.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import javax.xml.bind.JAXBException; + +import com.sap.sailing.resultimport.ResultDocumentDescriptor; +import com.sap.sailing.resultimport.ResultDocumentProvider; +import com.sap.sailing.resultimport.ResultUrlProvider; +import com.sap.sailing.xrr.resultimport.Parser; +import com.sap.sailing.xrr.resultimport.ParserFactory; +import com.sap.sailing.xrr.schema.RegattaResults; + +public abstract class UrlBasedXRRResultDocumentProvider implements ResultDocumentProvider { + private static final Logger logger = Logger.getLogger(UrlBasedXRRResultDocumentProvider.class.getName()); + + private final ResultUrlProvider resultUrlProvider; + private final ParserFactory parserFactory; + + public UrlBasedXRRResultDocumentProvider(ResultUrlProvider resultUrlProvider, ParserFactory parserFactory) { + this.resultUrlProvider = resultUrlProvider; + this.parserFactory = parserFactory; + } + + @Override + public Iterable getResultDocumentDescriptors() throws IOException { + List result = new ArrayList<>(); + for (URL url : resultUrlProvider.getUrls()) { + URLConnection eventResultConn = url.openConnection(); + + InputStream is = (InputStream) eventResultConn.getContent(); + Parser parser = parserFactory.createParser(is, url.toString()); + try { + RegattaResults xrrParserResult = parser.parse(); + if (xrrParserResult != null) { + List resultDocumentDescriptors = resolveResultDocumentDescriptors(xrrParserResult, url); + if(resultDocumentDescriptors != null) { + result.addAll(resultDocumentDescriptors); + } + } + } catch (JAXBException e) { + logger.severe("Could not parse XRR document from URL: " + url.toString()); + e.printStackTrace(); + } + + } + return result; + } + + abstract public List resolveResultDocumentDescriptors(RegattaResults xrrParserResult, URL url); +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1220_CharlstonRaceWeek2015_xrr.xml b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1220_CharlstonRaceWeek2015_xrr.xml new file mode 100644 index 00000000000..9f62db15ac3 --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/resources/event1220_CharlstonRaceWeek2015_xrr.xml @@ -0,0 +1,4769 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/CharlstonRaceWeek2015_ParserTest.java b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/CharlstonRaceWeek2015_ParserTest.java new file mode 100644 index 00000000000..62ef98e37bc --- /dev/null +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/CharlstonRaceWeek2015_ParserTest.java @@ -0,0 +1,125 @@ +package com.sap.sailing.yachtscoring.resultimport.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.DatatypeConverter; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import org.junit.Test; +import org.xml.sax.SAXException; + +import com.sap.sailing.domain.common.RegattaScoreCorrections; +import com.sap.sailing.domain.common.RegattaScoreCorrections.ScoreCorrectionsForRace; +import com.sap.sailing.domain.persistence.DomainObjectFactory; +import com.sap.sailing.domain.persistence.MongoObjectFactory; +import com.sap.sailing.resultimport.ResultDocumentDescriptor; +import com.sap.sailing.resultimport.ResultDocumentProvider; +import com.sap.sailing.resultimport.ResultUrlRegistry; +import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl; +import com.sap.sailing.resultimport.impl.ResultUrlRegistryImpl; +import com.sap.sailing.xrr.resultimport.ParserFactory; +import com.sap.sailing.xrr.schema.RegattaResults; +import com.sap.sailing.yachtscoring.resultimport.ScoreCorrectionProviderImpl; +import com.sap.sse.common.TimePoint; +import com.sap.sse.common.Util; +import com.sap.sse.common.impl.MillisecondsTimePoint; + +public class CharlstonRaceWeek2015_ParserTest { + private static final String CHARLSTONRACEWEEK2015_TESTFILE_XRR = "event1220_CharlstonRaceWeek2015_xrr.xml"; + private static final String CHARLSTONRACEWEEK2015_EVENT_NAME = "2015 Sperry Charleston Race Week, North Charleston, SC, USA"; + + private static final String BOAT_CLASS_J111 = "J 111"; + private static final String BOAT_CLASS_MELGES24 = "Melges 24"; + + private static final String RESOURCES = "resources/"; + + private InputStream getInputStream(String filename) throws FileNotFoundException, IOException { + return new FileInputStream(getFile(filename)); + } + + private File getFile(String filename) { + return new File(RESOURCES + filename); + } + + private ResultDocumentProvider getTestDocumentProvider() { + return new ResultDocumentProvider() { + @Override + public Iterable getResultDocumentDescriptors() throws IOException { + try { + List result = new ArrayList(); + + Date _J111Date = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); + Date _Melges24Date = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); + result.add(new ResultDocumentDescriptorImpl(getInputStream(CHARLSTONRACEWEEK2015_TESTFILE_XRR), + null, new MillisecondsTimePoint(_J111Date), CHARLSTONRACEWEEK2015_EVENT_NAME , null, BOAT_CLASS_J111)); + result.add(new ResultDocumentDescriptorImpl(getInputStream(CHARLSTONRACEWEEK2015_TESTFILE_XRR), + null, new MillisecondsTimePoint(_Melges24Date), CHARLSTONRACEWEEK2015_EVENT_NAME , null, BOAT_CLASS_MELGES24)); + + return result; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + } + + @Test + public void testSimpleParsingSomeYachtscoringDocuments() throws JAXBException, IOException { + RegattaResults regattaResults = ParserFactory.INSTANCE.createParser(getInputStream(CHARLSTONRACEWEEK2015_TESTFILE_XRR), CHARLSTONRACEWEEK2015_EVENT_NAME).parse(); + assertNotNull(regattaResults); + } + + @Test + public void testScoreCorrectionProviderFeedingAndHasResults() throws IOException, SAXException, + ParserConfigurationException, JAXBException { + ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mock(MongoObjectFactory.class), + mock(DomainObjectFactory.class)); + ScoreCorrectionProviderImpl scoreCorrectionProvider = new ScoreCorrectionProviderImpl( + getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); + Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); + + Set> resultsForKeyWestRaceWeek = hasResultsFor.get(CHARLSTONRACEWEEK2015_EVENT_NAME); + assertNotNull(resultsForKeyWestRaceWeek); + + assertEquals(1, resultsForKeyWestRaceWeek.size()); + } + + @Test + public void testScoreCorrectionProvider() throws Exception { + ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mock(MongoObjectFactory.class), mock(DomainObjectFactory.class)); + ScoreCorrectionProviderImpl scoreCorrectionProvider = new ScoreCorrectionProviderImpl( + getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); + Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); + Set> resultsForKeyWestRaceWeek = hasResultsFor.get(CHARLSTONRACEWEEK2015_EVENT_NAME); + com.sap.sse.common.Util.Pair resultForJ111 = null; + for(com.sap.sse.common.Util.Pair result: resultsForKeyWestRaceWeek) { + if(result.getA().equals(BOAT_CLASS_J111)) { + resultForJ111 = result; + break; + } + } + assertNotNull(resultForJ111); + + RegattaScoreCorrections _J111Result = scoreCorrectionProvider.getScoreCorrections(CHARLSTONRACEWEEK2015_EVENT_NAME, BOAT_CLASS_J111, + resultForJ111.getB()); + assertNotNull(_J111Result); + Iterable scoreCorrectionsForRaces = _J111Result.getScoreCorrectionsForRaces(); + assertNotNull(scoreCorrectionsForRaces); + assertEquals(8, Util.size(scoreCorrectionsForRaces)); + } + +} diff --git a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/KeyWestRaceWeek2016_ParserTest.java similarity index 53% rename from java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java rename to java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/KeyWestRaceWeek2016_ParserTest.java index fbf922553ea..86f2546ad02 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/ParserTest.java +++ b/java/com.sap.sailing.yachtscoring.resultimport.test/src/com/sap/sailing/yachtscoring/resultimport/test/KeyWestRaceWeek2016_ParserTest.java @@ -22,6 +22,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Test; import org.xml.sax.SAXException; +import com.sap.sailing.domain.common.RegattaScoreCorrections; +import com.sap.sailing.domain.common.RegattaScoreCorrections.ScoreCorrectionsForRace; import com.sap.sailing.domain.persistence.DomainObjectFactory; import com.sap.sailing.domain.persistence.MongoObjectFactory; import com.sap.sailing.resultimport.ResultDocumentDescriptor; @@ -33,12 +35,15 @@ import com.sap.sailing.xrr.resultimport.ParserFactory; import com.sap.sailing.xrr.schema.RegattaResults; import com.sap.sailing.yachtscoring.resultimport.ScoreCorrectionProviderImpl; import com.sap.sse.common.TimePoint; +import com.sap.sse.common.Util; import com.sap.sse.common.impl.MillisecondsTimePoint; -public class ParserTest { - private static final String SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK = "event1390_KeyWestRaceWeek2016_xrr.xml"; - private static final String KEYWESTRACEWEEEK_EVENT_NAME = "Key West Race Week 2016"; +public class KeyWestRaceWeek2016_ParserTest { + private static final String KEYWESTRACEWEEEK2016_TESTFILE_XRR = "event1390_KeyWestRaceWeek2016_xrr.xml"; + private static final String KEYWESTRACEWEEEK2016_EVENT_NAME = "Key West Race Week 2016"; + private static final String BOAT_CLASS_J111 = "J 111"; + private static final String BOAT_CLASS_MELGES24 = "Melges 24"; private static final String RESOURCES = "resources/"; @@ -58,8 +63,11 @@ public class ParserTest { List result = new ArrayList(); Date _J111Date = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); - result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK), - null, new MillisecondsTimePoint(_J111Date), KEYWESTRACEWEEEK_EVENT_NAME , null, BOAT_CLASS_J111)); + Date _Melges24Date = DatatypeConverter.parseDateTime("2016-01-19T12:55:08.000Z").getTime(); + result.add(new ResultDocumentDescriptorImpl(getInputStream(KEYWESTRACEWEEEK2016_TESTFILE_XRR), + null, new MillisecondsTimePoint(_J111Date), KEYWESTRACEWEEEK2016_EVENT_NAME , null, BOAT_CLASS_J111)); + result.add(new ResultDocumentDescriptorImpl(getInputStream(KEYWESTRACEWEEEK2016_TESTFILE_XRR), + null, new MillisecondsTimePoint(_Melges24Date), KEYWESTRACEWEEEK2016_EVENT_NAME , null, BOAT_CLASS_MELGES24)); return result; } catch (Exception e) { @@ -71,9 +79,8 @@ public class ParserTest { @Test public void testSimpleParsingSomeYachtscoringDocuments() throws JAXBException, IOException { - RegattaResults r1 = ParserFactory.INSTANCE.createParser(getInputStream(SAMPLE_INPUT_NAME_KEYWESTRACEWEEEK), KEYWESTRACEWEEEK_EVENT_NAME).parse(); - assertNotNull(r1); - + RegattaResults regattaResults = ParserFactory.INSTANCE.createParser(getInputStream(KEYWESTRACEWEEEK2016_TESTFILE_XRR), KEYWESTRACEWEEEK2016_EVENT_NAME).parse(); + assertNotNull(regattaResults); } @Test @@ -85,34 +92,34 @@ public class ParserTest { getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); - Set> resultsForKeyWestRaceWeek = hasResultsFor.get(KEYWESTRACEWEEEK_EVENT_NAME); + Set> resultsForKeyWestRaceWeek = hasResultsFor.get(KEYWESTRACEWEEEK2016_EVENT_NAME); assertNotNull(resultsForKeyWestRaceWeek); - assertEquals(3, resultsForKeyWestRaceWeek.size()); + assertEquals(1, resultsForKeyWestRaceWeek.size()); } -// @Test -// public void testScoreCorrectionProvider() throws Exception { -// ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mock(MongoObjectFactory.class), -// mock(DomainObjectFactory.class)); -// ScoreCorrectionProviderImpl scoreCorrectionProvider = new ScoreCorrectionProviderImpl( -// getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); -// Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); -// Set> resultsForYES = hasResultsFor.get(YES_EVENT_NAME); -// com.sap.sse.common.Util.Pair resultFor29er = null; -// for(com.sap.sse.common.Util.Pair result: resultsForYES) { -// if(result.getA().equals(ISAF_ID_29ER)) { -// resultFor29er = result; -// break; -// } -// } -// assertNotNull(resultFor29er); -// -// RegattaScoreCorrections _29erResult = scoreCorrectionProvider.getScoreCorrections(YES_EVENT_NAME, ISAF_ID_29ER , resultFor29er.getB()); -// assertNotNull(_29erResult); -// Iterable scoreCorrectionsForRaces = _29erResult.getScoreCorrectionsForRaces(); -// assertNotNull(scoreCorrectionsForRaces); -// assertEquals(8, Util.size(scoreCorrectionsForRaces)); -// } + @Test + public void testScoreCorrectionProvider() throws Exception { + ResultUrlRegistry resultUrlRegistry = new ResultUrlRegistryImpl(mock(MongoObjectFactory.class), mock(DomainObjectFactory.class)); + ScoreCorrectionProviderImpl scoreCorrectionProvider = new ScoreCorrectionProviderImpl( + getTestDocumentProvider(), ParserFactory.INSTANCE, resultUrlRegistry); + Map>> hasResultsFor = scoreCorrectionProvider.getHasResultsForBoatClassFromDateByEventName(); + Set> resultsForKeyWestRaceWeek = hasResultsFor.get(KEYWESTRACEWEEEK2016_EVENT_NAME); + com.sap.sse.common.Util.Pair resultForJ111 = null; + for(com.sap.sse.common.Util.Pair result: resultsForKeyWestRaceWeek) { + if(result.getA().equals(BOAT_CLASS_J111)) { + resultForJ111 = result; + break; + } + } + assertNotNull(resultForJ111); + + RegattaScoreCorrections _J111Result = scoreCorrectionProvider.getScoreCorrections(KEYWESTRACEWEEEK2016_EVENT_NAME, BOAT_CLASS_J111, + resultForJ111.getB()); + assertNotNull(_J111Result); + Iterable scoreCorrectionsForRaces = _J111Result.getScoreCorrectionsForRaces(); + assertNotNull(scoreCorrectionsForRaces); + assertEquals(8, Util.size(scoreCorrectionsForRaces)); + } } diff --git a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java index 73353e3afdc..091ccb70303 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java +++ b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/ScoreCorrectionProviderImpl.java @@ -46,7 +46,7 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res } public ScoreCorrectionProviderImpl(ParserFactory parserFactory, ResultUrlRegistry resultUrlRegistry) { - this.documentProvider = new YachtscoringResultDocumentProvider(this); + this.documentProvider = new YachtscoringResultDocumentProvider(this, parserFactory); this.parserFactory = parserFactory; this.resultUrlRegistry = resultUrlRegistry; } @@ -118,11 +118,7 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res private Parser resolveParser(String eventName, String boatClassName) throws IOException { Parser result = null; for (ResultDocumentDescriptor resultDocDescr : documentProvider.getResultDocumentDescriptors()) { - String boatClassAndGenderType = resultDocDescr.getBoatClass(); - if(resultDocDescr.getCompetitorGenderType() != null) { - boatClassAndGenderType += ", " + resultDocDescr.getCompetitorGenderType().name(); - } - if(eventName.equals(resultDocDescr.getEventName()) && boatClassName.equals(boatClassAndGenderType)) { + if(eventName.equals(resultDocDescr.getEventName()) && boatClassName.equals(resultDocDescr.getBoatClass())) { result = parserFactory.createParser(resultDocDescr.getInputStream(), resultDocDescr.getEventName()); break; } @@ -137,6 +133,6 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res @Override public String getOptionalSampleURL() { - return "http://www.yachtscoring.com/results_xrr.cfm?Spec_Race=6&eid=1220"; + return "http://www.yachtscoring.com/xrr/1220_ys_xrr.xml"; } } diff --git a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java index de650cd9a18..9abdf098d35 100644 --- a/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java +++ b/java/com.sap.sailing.yachtscoring.resultimport/src/com/sap/sailing/yachtscoring/resultimport/YachtscoringResultDocumentProvider.java @@ -4,51 +4,55 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; -import com.sap.sailing.yachtscoring.EventResultDescriptor; -import com.sap.sailing.yachtscoring.YachtscoringEventResultsParserImpl; -import com.sap.sailing.yachtscoring.RegattaResultDescriptor; import com.sap.sailing.resultimport.ResultDocumentDescriptor; -import com.sap.sailing.resultimport.ResultDocumentProvider; import com.sap.sailing.resultimport.ResultUrlProvider; import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl; -import com.sap.sse.common.impl.MillisecondsTimePoint; +import com.sap.sailing.xrr.resultimport.ParserFactory; +import com.sap.sailing.xrr.resultimport.impl.UrlBasedXRRResultDocumentProvider; +import com.sap.sailing.xrr.resultimport.impl.XRRParserUtil; +import com.sap.sailing.xrr.schema.Division; +import com.sap.sailing.xrr.schema.Event; +import com.sap.sailing.xrr.schema.RegattaResults; +import com.sap.sse.common.TimePoint; -public class YachtscoringResultDocumentProvider implements ResultDocumentProvider { - private final ResultUrlProvider resultUrlProvider; +/** + * A yachtscoring.com specific result document provider reading the complete XRR document of an event to find all regattas inside. + * @author Frank + * + */ +public class YachtscoringResultDocumentProvider extends UrlBasedXRRResultDocumentProvider { - public YachtscoringResultDocumentProvider(final ResultUrlProvider resultUrlProvider) { - this.resultUrlProvider = resultUrlProvider; + public YachtscoringResultDocumentProvider(ResultUrlProvider resultUrlProvider, ParserFactory parserFactory) { + super(resultUrlProvider, parserFactory); } - @Override - public Iterable getResultDocumentDescriptors() throws IOException { + public List resolveResultDocumentDescriptors(RegattaResults xrrParserResult, URL url) { List result = new ArrayList<>(); - YachtscoringEventResultsParserImpl parser = new YachtscoringEventResultsParserImpl(); - for (URL url : resultUrlProvider.getUrls()) { - URLConnection eventResultConn = url.openConnection(); - EventResultDescriptor eventResult = parser.getEventResult((InputStream) eventResultConn.getContent()); - if (eventResult != null) { - for (RegattaResultDescriptor regattaResult : eventResult.getRegattaResults()) { - // Depending on the regatta type the boat class in the XRR is set or not (in the division tag) - // Olympic boat classes -> IFClassID="2.4M" Title="2.4M open" - // International boat classes -> IFClassID="" Title="Coachboat" - // Open boat classes (ORC) -> IFClassID="" Title="Welcome Race ORC-Club" - // -> therefore we need to take the regatta title as boat class where the IsafID is not available - String boatClass = regattaResult.getIsafId() != null && !regattaResult.getIsafId().isEmpty() ? regattaResult.getIsafId() : regattaResult.getName(); - if (regattaResult.getIsFinal() != null && regattaResult.getPublishedAt() != null) { - if (regattaResult.getIsFinal() && regattaResult.getXrrFinalUrl() != null) { - URLConnection regattaResultConn = regattaResult.getXrrFinalUrl().openConnection(); - result.add(new ResultDocumentDescriptorImpl((InputStream) regattaResultConn.getContent(), - regattaResult.getXrrPreliminaryUrl().toString(), new MillisecondsTimePoint(regattaResult.getPublishedAt()), - eventResult.getName(), regattaResult.getName(), boatClass, regattaResult.getCompetitorGenderType())); - } else if (regattaResult.getXrrPreliminaryUrl() != null) { - URLConnection regattaResultConn = regattaResult.getXrrPreliminaryUrl().openConnection(); - result.add(new ResultDocumentDescriptorImpl((InputStream) regattaResultConn.getContent(), - regattaResult.getXrrPreliminaryUrl().toString(), new MillisecondsTimePoint(regattaResult.getPublishedAt()), - eventResult.getName(), regattaResult.getName(), boatClass, regattaResult.getCompetitorGenderType())); + TimePoint xrrDocumentDateAndTime = XRRParserUtil.calculateTimePointForRegattaResults(xrrParserResult); + + for (Object o : xrrParserResult.getPersonOrBoatOrTeam()) { + if (o instanceof Event) { + Event event = (Event) o; + String eventName = event.getTitle(); + for(Object d: event.getRaceOrDivisionOrRegattaSeriesResult()) { + if (d instanceof Division) { + Division division = (Division) d; + String regattaName = division.getTitle(); + String boatClass = division.getTitle(); + try { + String requestUrl = url.toString() + "?Class=" + URLEncoder.encode(boatClass, "UTF-8"); + URL urlByClass = new URL(requestUrl); + URLConnection eventResultConn = urlByClass.openConnection(); + InputStream is = (InputStream) eventResultConn.getContent(); + + result.add(new ResultDocumentDescriptorImpl(is, requestUrl, xrrDocumentDateAndTime, + eventName, regattaName, boatClass)); + } catch (IOException e) { + e.printStackTrace(); } } } From 35de1b61b021e05e52f7a8ce4f409123d2efa110 Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Thu, 24 Mar 2016 10:32:43 +0100 Subject: [PATCH 072/178] refactor multiple wind input dialog --- .../res/layout/wind_list_item.xml | 11 -- .../res/layout/wind_multiple_dialog.xml | 14 -- .../ui/fragments/raceinfo/WindFragment.java | 121 +++++------------- 3 files changed, 31 insertions(+), 115 deletions(-) delete mode 100644 mobile/com.sap.sailing.racecommittee.app/res/layout/wind_list_item.xml delete mode 100644 mobile/com.sap.sailing.racecommittee.app/res/layout/wind_multiple_dialog.xml diff --git a/mobile/com.sap.sailing.racecommittee.app/res/layout/wind_list_item.xml b/mobile/com.sap.sailing.racecommittee.app/res/layout/wind_list_item.xml deleted file mode 100644 index 779a62e9557..00000000000 --- a/mobile/com.sap.sailing.racecommittee.app/res/layout/wind_list_item.xml +++ /dev/null @@ -1,11 +0,0 @@ - - \ No newline at end of file diff --git a/mobile/com.sap.sailing.racecommittee.app/res/layout/wind_multiple_dialog.xml b/mobile/com.sap.sailing.racecommittee.app/res/layout/wind_multiple_dialog.xml deleted file mode 100644 index 71816ba4982..00000000000 --- a/mobile/com.sap.sailing.racecommittee.app/res/layout/wind_multiple_dialog.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/raceinfo/WindFragment.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/raceinfo/WindFragment.java index 6fffd92452e..3f71c638315 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/raceinfo/WindFragment.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/raceinfo/WindFragment.java @@ -1,5 +1,12 @@ package com.sap.sailing.racecommittee.app.ui.fragments.raceinfo; +import java.lang.ref.WeakReference; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; + import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; @@ -18,12 +25,9 @@ import android.view.View; import android.view.ViewGroup; import android.webkit.WebSettings; import android.webkit.WebView; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; -import android.widget.ListView; import android.widget.NumberPicker; import android.widget.TextView; @@ -34,7 +38,6 @@ import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; import com.sap.sailing.android.shared.logging.ExLog; import com.sap.sailing.android.shared.util.AppUtils; -import com.sap.sailing.android.shared.util.ScreenHelper; import com.sap.sailing.android.shared.util.ViewHelper; import com.sap.sailing.domain.common.Bearing; import com.sap.sailing.domain.common.Position; @@ -63,13 +66,6 @@ import com.sap.sailing.racecommittee.app.utils.WindHelper; import com.sap.sse.common.TimePoint; import com.sap.sse.common.impl.MillisecondsTimePoint; -import java.lang.ref.WeakReference; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; - public class WindFragment extends BaseFragment implements CompassDirectionListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener, OnRaceUpdatedListener { private final static String TAG = WindFragment.class.getName(); @@ -534,8 +530,31 @@ public class WindFragment extends BaseFragment implements CompassDirectionListen } private void showWindDialog() { + ArrayList races = new ArrayList<>(); + for (ManagedRace race : mManagedRaces) { + races.add(RaceHelper.getShortReverseRaceName(race, " / ", getRace())); + } + mSelectedRaces.clear(); + mSelectedRaces.addAll(RaceHelper.getPreSelectedRaces(mRacesByGroup, getRace())); + boolean[] selected = new boolean[mManagedRaces.size()]; + for (int i = 0; i < mManagedRaces.size(); i++) { + selected[i] = mSelectedRaces.contains(mManagedRaces.get(i)); + } + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog); builder.setTitle(getString(R.string.wind_select_race)); + builder.setMultiChoiceItems(races.toArray(new String[races.size()]), selected, new DialogInterface.OnMultiChoiceClickListener() { + @Override + public void onClick(DialogInterface dialog, int which, boolean isChecked) { + ManagedRace race = mManagedRaces.get(which); + if (mSelectedRaces.contains(race)) { + mSelectedRaces.remove(race); + } + if (isChecked) { + mSelectedRaces.add(race); + } + } + }); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -544,75 +563,10 @@ public class WindFragment extends BaseFragment implements CompassDirectionListen } } }); - builder.setNegativeButton(R.string.cancel, null); - builder.setView(setupDialogView()); + builder.setNegativeButton(android.R.string.cancel, null); builder.show(); } - private View setupDialogView() { - LayoutInflater inflater = LayoutInflater.from(getActivity()); - View view = inflater.inflate(R.layout.wind_multiple_dialog, null); - ListView racesList = (ListView) view.findViewById(R.id.wind_races_list); - racesList.setAdapter(new WindAdapter(getActivity(), mManagedRaces)); - racesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); - racesList.setOnItemClickListener(new ItemClickListener()); - preselectRacesInDialog(racesList); - - ViewGroup.LayoutParams layoutParams = racesList.getLayoutParams(); - layoutParams.height = 49 * mManagedRaces.size(); - int screenHeight = (int) (ScreenHelper.on(getActivity()).getScreenHeight() * 0.65); - if (layoutParams.height > screenHeight) { - layoutParams.height = screenHeight; - } - view.setLayoutParams(layoutParams); - - return view; - } - - private void preselectRacesInDialog(ListView racesList) { - mSelectedRaces.clear(); - mSelectedRaces.addAll(RaceHelper.getPreSelectedRaces(mRacesByGroup, getRace())); - for (int index = 0; index < mManagedRaces.size(); index++) { - ManagedRace race = mManagedRaces.get(index); - if (race != null) { - racesList.setItemChecked(index, mSelectedRaces.contains(race)); - } - } - } - - private static class WindAdapter extends ArrayAdapter { - - public WindAdapter(Context context, List races) { - super(context, R.layout.wind_list_item, wrap(races)); - } - - private static List wrap(List races) { - List wrapped = new ArrayList<>(); - for (ManagedRace race : races) { - wrapped.add(new ManagedRaceItem(race)); - } - return wrapped; - } - - } - - private static class ManagedRaceItem { - - private RaceGroupSeriesFleet group; - private ManagedRace race; - - public ManagedRaceItem(ManagedRace race) { - this.race = race; - this.group = new RaceGroupSeriesFleet(race); - } - - @Override - public String toString() { - return String.format("%s - %s", group.getDisplayName(true), race.getRaceName()); - } - - } - private static class IsTrackedReceiver extends BroadcastReceiver { private WeakReference