Author: adietish
Date: 2012-01-23 13:18:05 -0500 (Mon, 23 Jan 2012)
New Revision: 38034
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/AbstractGoogleAnalyticsParameters.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/IGoogleAnalyticsParameters.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/JBossToolsEclipseEnvironment.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java
Log:
[JBIDE-10653] renamed #getCentralEnabled to #getEvent, added testcase
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/AbstractGoogleAnalyticsParameters.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/AbstractGoogleAnalyticsParameters.java 2012-01-23
18:07:12 UTC (rev 38033)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/AbstractGoogleAnalyticsParameters.java 2012-01-23
18:18:05 UTC (rev 38034)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.usage.googleanalytics;
+import java.text.MessageFormat;
+
/**
* @author Andre Dietisheim
*/
@@ -47,4 +49,33 @@
public String getUserDefined() {
return userDefined;
}
+
+ public static class GoogleAnalyticsEvent {
+
+ private String name;
+ private String label;
+ private String value;
+
+ public GoogleAnalyticsEvent(String name, String label, String value) {
+ this.name = name;
+ this.label = label;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String toString() {
+ return MessageFormat.format("5({0}*{1}*{2})", name, label, value);
+ }
+ }
}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java 2012-01-23
18:07:12 UTC (rev 38033)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java 2012-01-23
18:18:05 UTC (rev 38034)
@@ -70,7 +70,10 @@
// appendParameter(IGoogleAnalyticsParameters.PARAM_HID,
// getRandomNumber(), builder);
appendParameter(IGoogleAnalyticsParameters.PARAM_FLASH_VERSION,
googleParameters.getFlashVersion(), builder);
- appendParameter(IGoogleAnalyticsParameters.PARAM_EVENT_TRACKING,
googleParameters.getCentralEnabled(), builder);
+ /**
+ * TODO: support multiple events. Obviously these would just get appended to the very
same string
+ */
+ appendParameter(IGoogleAnalyticsParameters.PARAM_EVENT_TRACKING,
googleParameters.getEvent().toString(), builder);
appendParameter(IGoogleAnalyticsParameters.PARAM_REFERRAL,
googleParameters.getReferral(), builder);
appendParameter(IGoogleAnalyticsParameters.PARAM_PAGE_REQUEST, focusPoint.getURI(),
builder);
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/IGoogleAnalyticsParameters.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/IGoogleAnalyticsParameters.java 2012-01-23
18:07:12 UTC (rev 38033)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/IGoogleAnalyticsParameters.java 2012-01-23
18:18:05 UTC (rev 38034)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.usage.googleanalytics;
+import
org.jboss.tools.usage.googleanalytics.AbstractGoogleAnalyticsParameters.GoogleAnalyticsEvent;
+
/**
* An interface that provides methods for all parameters that google analytics
* needs to know about.
@@ -112,7 +114,10 @@
*/
public String getUserDefined();
- public String getCentralEnabled();
+ /**
+ * TODO: support multiple events.
+ */
+ public GoogleAnalyticsEvent getEvent();
public String getCentralEnabledValue();
}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/JBossToolsEclipseEnvironment.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/JBossToolsEclipseEnvironment.java 2012-01-23
18:07:12 UTC (rev 38033)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/JBossToolsEclipseEnvironment.java 2012-01-23
18:18:05 UTC (rev 38034)
@@ -27,14 +27,12 @@
public class JBossToolsEclipseEnvironment extends AbstractEclipseEnvironment implements
IJBossToolsEclipseEnvironment {
private static final String NOT_INSTALLED = "N/A"; //$NON-NLS-1$
- private static final String CLOSED_BRACKET = ")"; //$NON-NLS-1$
private static final String TRUE = "true";
private static final String FALSE = "false";
private static final char JBOSS_COMPONENTS_DELIMITER = '-';
private static final String JBOSS_CENTRAL_PLUGIN_ID =
"org.jboss.tools.central"; //$NON-NLS-1$
private static final String SHOW_JBOSS_CENTRAL_ON_STARTUP =
"showJBossCentralOnStartup"; //$NON-NLS-1$
private static final boolean SHOW_JBOSS_CENTRAL_ON_STARTUP_DEFAULT_VALUE = true;
- private static final String JBOSS_CENTRAL_PARAMETER =
"5(central*showOnStartup*"; //$NON-NLS-1$
public JBossToolsEclipseEnvironment(String accountName, String hostName,
IEclipsePreferences preferences) {
super(accountName, hostName, preferences);
@@ -68,8 +66,11 @@
return getLinuxDistroNameAndVersion() != null;
}
- public String getCentralEnabled() {
- return JBOSS_CENTRAL_PARAMETER + getCentralEnabledValue() + CLOSED_BRACKET;
+ /**
+ * TODO: support multiple events.
+ */
+ public GoogleAnalyticsEvent getEvent() {
+ return new GoogleAnalyticsEvent("central", "showOnStartup",
getCentralEnabledValue());
}
public String getCentralEnabledValue() {
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java 2012-01-23
18:07:12 UTC (rev 38033)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java 2012-01-23
18:18:05 UTC (rev 38034)
@@ -13,6 +13,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.jboss.tools.usage.googleanalytics.GoogleAnalyticsUrlStrategy;
@@ -91,6 +92,19 @@
assertEquals(3, eclipseEnvironment.getVisitCount());
}
+ @Test
+ public void verifyCentralIsStarted() throws IOException {
+ IFocusPoint focusPoint = new FocusPoint("testing").setChild(new
FocusPoint("strategy"));
+ String url = urlStrategy.build(focusPoint);
+
+ String centralEnabled = new
ReportingEclipseEnvironmentFake().getCentralEnabledValue();
+
+ assertTrue(areEqualParameterValues(
+ IGoogleAnalyticsParameters.PARAM_EVENT_TRACKING
+ , url
+ , IGoogleAnalyticsParameters.PARAM_EVENT_TRACKING +
"=5(central*showOnStartup*" + centralEnabled + ")&"));
+ }
+
private boolean areEqualParameterValues(String paramName, String url, String targetUrl)
{
return areEqualParameterValues(paramName, url, targetUrl,
String.valueOf(IGoogleAnalyticsParameters.AMPERSAND));
}