mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-18 19:59:09 +00:00
remove Alias(Factory)? stuff from Selenium project;
this lets us remove an old version of cglib which is no longer supported and doesn't work with Java 17. The usages have been re-designed to use the regular cell table entry iteration methods without problems.
This commit is contained in:
@@ -4,6 +4,5 @@
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/cglib-nodep-2.2.3.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -18,8 +18,7 @@ Require-Bundle: org.hamcrest;bundle-version="2.2.0",
|
||||
org.mongodb.driver-sync;bundle-version="4.3.1",
|
||||
com.sun.jersey;bundle-version="1.17.0",
|
||||
com.sap.sse.security
|
||||
Bundle-ClassPath: lib/cglib-nodep-2.2.3.jar,
|
||||
.
|
||||
Bundle-ClassPath: .
|
||||
Automatic-Module-Name: com.sap.sailing.selenium.test
|
||||
Import-Package: javax.ws.rs.core;version="1.1.1",
|
||||
org.apache.http.client;version="4.5.5",
|
||||
|
||||
@@ -3,5 +3,4 @@ source.. = src/,\
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
test-environment-configuration.xsd,\
|
||||
lib/cglib-nodep-2.2.3.jar
|
||||
test-environment-configuration.xsd
|
||||
|
||||
Binary file not shown.
+2
-13
@@ -1,7 +1,5 @@
|
||||
package com.sap.sailing.selenium.pages.adminconsole.leaderboard;
|
||||
|
||||
import static com.sap.sailing.selenium.pages.gwt.query.Alias.$;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
@@ -12,8 +10,6 @@ import com.sap.sailing.selenium.pages.adminconsole.ActionsHelper;
|
||||
import com.sap.sailing.selenium.pages.gwt.CellTablePO;
|
||||
import com.sap.sailing.selenium.pages.gwt.DataEntryPO;
|
||||
import com.sap.sailing.selenium.pages.gwt.GenericCellTablePO;
|
||||
import com.sap.sailing.selenium.pages.gwt.query.Alias;
|
||||
import com.sap.sailing.selenium.pages.gwt.query.TableQuery;
|
||||
|
||||
public class LeaderboardGroupConfigurationPanelPO extends PageArea {
|
||||
@FindBy(how = BySeleniumId.class, using = "CreateLeaderboardGroupButton")
|
||||
@@ -81,14 +77,7 @@ public class LeaderboardGroupConfigurationPanelPO extends PageArea {
|
||||
}
|
||||
|
||||
private DataEntryPO findLeaderboardGroup(String name) {
|
||||
CellTablePO<DataEntryPO> table = getLeaderboardGroupsTable();
|
||||
final DataEntryPO alias = Alias.alias(DataEntryPO.class);
|
||||
TableQuery<DataEntryPO> query = new TableQuery<>();
|
||||
query.from(table)
|
||||
.where(
|
||||
$(alias.getColumnContent("Name")).eq(name)
|
||||
);
|
||||
|
||||
return query.firstResult();
|
||||
final CellTablePO<DataEntryPO> table = getLeaderboardGroupsTable();
|
||||
return table.getEntries().stream().filter(e->e.getColumnContent("Name").equals(name)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-15
@@ -1,22 +1,15 @@
|
||||
package com.sap.sailing.selenium.pages.adminconsole.leaderboard;
|
||||
|
||||
import static com.sap.sailing.selenium.pages.gwt.query.Alias.$;
|
||||
|
||||
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.gwt.CellTablePO;
|
||||
import com.sap.sailing.selenium.pages.gwt.DataEntryPO;
|
||||
import com.sap.sailing.selenium.pages.gwt.GenericCellTablePO;
|
||||
|
||||
import com.sap.sailing.selenium.pages.gwt.query.Alias;
|
||||
import com.sap.sailing.selenium.pages.gwt.query.TableQuery;
|
||||
|
||||
public class LeaderboardGroupDetailsPanelPO extends PageArea {
|
||||
@FindBy(how = BySeleniumId.class, using = "LeaderboardsFilterTextBox")
|
||||
private WebElement leaderboardsFilterTextBox;
|
||||
@@ -40,14 +33,8 @@ public class LeaderboardGroupDetailsPanelPO extends PageArea {
|
||||
}
|
||||
|
||||
public DataEntryPO findLeaderboardEntry(String name) {
|
||||
CellTablePO<DataEntryPO> table = getLeaderboardsTable();
|
||||
DataEntryPO alias = Alias.alias(DataEntryPO.class);
|
||||
|
||||
TableQuery<DataEntryPO> query = new TableQuery<>();
|
||||
query.from(table).
|
||||
where($(alias.getColumnContent("Leaderboard Name")).eq(name));
|
||||
|
||||
return query.firstResult();
|
||||
final CellTablePO<DataEntryPO> table = getLeaderboardsTable();
|
||||
return table.getEntries().stream().filter(e->e.getColumnContent("Leaderboard Name").equals(name)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public void filterLeaderboards(String filterText) {
|
||||
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
package com.sap.sailing.selenium.pages.gwt.query;
|
||||
|
||||
import com.sap.sailing.selenium.pages.gwt.query.path.BooleanPath;
|
||||
import com.sap.sailing.selenium.pages.gwt.query.path.StringPath;
|
||||
|
||||
public class Alias {
|
||||
private static final AliasFactory factory = new AliasFactory();
|
||||
|
||||
public static <A> A alias(Class<A> clazz) {
|
||||
return factory.createAlias(clazz);
|
||||
}
|
||||
|
||||
public static <D extends Expression<?>> D $() {
|
||||
return factory.getCurrentExpressionAndReset();
|
||||
}
|
||||
|
||||
public static StringPath $(String value) {
|
||||
return $();
|
||||
}
|
||||
|
||||
public static BooleanPath $(Boolean value) {
|
||||
return $();
|
||||
}
|
||||
|
||||
public static BooleanPath $(boolean value) {
|
||||
return $();
|
||||
}
|
||||
|
||||
// public static NumberPath $(Byte value) {
|
||||
// return $();
|
||||
// }
|
||||
|
||||
// public static NumberPath $(byte value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(Short value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(short value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(Integer value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(int value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(Long value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(long value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(Float value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(float value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(Double value) {
|
||||
// return $();
|
||||
// }
|
||||
//
|
||||
// public static NumberPath $(double value) {
|
||||
// return $();
|
||||
// }
|
||||
|
||||
public static void resetAlias() {
|
||||
factory.reset();
|
||||
}
|
||||
}
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
package com.sap.sailing.selenium.pages.gwt.query;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import net.sf.cglib.proxy.Enhancer;
|
||||
import net.sf.cglib.proxy.MethodInterceptor;
|
||||
import net.sf.cglib.proxy.MethodProxy;
|
||||
|
||||
public class AliasFactory {
|
||||
public interface ManagedObject {
|
||||
/**
|
||||
* <p></p>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
/*Expression<?>*/ Object __mappedPath();
|
||||
}
|
||||
|
||||
private class MethodAccessTracker implements MethodInterceptor {
|
||||
private static final String TO_STRING = "toString";
|
||||
private static final String HASH_CODE = "hashCode";
|
||||
private static final String MAPPED_PATH = "__mappedPath";
|
||||
|
||||
private final Expression<?> hostExpression;
|
||||
|
||||
public MethodAccessTracker(Expression<?> host) {
|
||||
this.hostExpression = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy) throws Throwable {
|
||||
String methodName = method.getName();
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
Class<?> returnType = method.getReturnType();
|
||||
//Type genericReturnType = method.getGenericReturnType();
|
||||
|
||||
if(Modifier.isPublic(method.getModifiers())) {
|
||||
if (MAPPED_PATH.equals(methodName) && parameterTypes.length == 0)
|
||||
return this.hostExpression;
|
||||
|
||||
if (TO_STRING.equals(methodName) && parameterTypes.length == 0)
|
||||
return this.hostExpression.toString();
|
||||
|
||||
if (HASH_CODE.equals(methodName) && parameterTypes.length == 0)
|
||||
return Integer.valueOf(this.hostExpression.hashCode());
|
||||
|
||||
PathMetadata<?> metadata = getOrCreatePathMetadata(method, args);
|
||||
Path<?> path = PathFactory.createPath(returnType, metadata);
|
||||
|
||||
AliasFactory.this.setCurrentExpression(path);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private PathMetadata<?> getOrCreatePathMetadata(Method method, Object[] args) {
|
||||
return new PathMetadata<>((Path<?>) this.hostExpression, method, args);
|
||||
}
|
||||
}
|
||||
|
||||
private final ThreadLocal<Expression<?>> current = new ThreadLocal<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <A extends Expression<?>> A getCurrentExpression() {
|
||||
return (A) this.current.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the current thread bound expression and resets it.</p>
|
||||
*
|
||||
* @param <A>
|
||||
*
|
||||
* @return
|
||||
* The current thread bound expression.
|
||||
*/
|
||||
public <A extends Expression<?>> A getCurrentExpressionAndReset() {
|
||||
A current = getCurrentExpression();
|
||||
|
||||
reset();
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the thread bound expression
|
||||
*/
|
||||
public void reset() {
|
||||
setCurrentExpression(null);
|
||||
}
|
||||
|
||||
public <A> A createAlias(Class<A> clazz) {
|
||||
return createProxy(clazz, new Class[0], new Object[0], null);
|
||||
}
|
||||
|
||||
protected void setCurrentExpression(Expression<?> expression) {
|
||||
this.current.set(expression);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <A> A createProxy(Class<A> clazz, Class<?>[] argumentTypes, Object[] arguments, Expression<?> path) {
|
||||
Enhancer enhancer = new Enhancer();
|
||||
enhancer.setClassLoader(AliasFactory.class.getClassLoader());
|
||||
|
||||
if (clazz.isInterface()) {
|
||||
enhancer.setInterfaces(new Class[] {clazz, ManagedObject.class});
|
||||
} else {
|
||||
enhancer.setSuperclass(clazz);
|
||||
enhancer.setInterfaces(new Class[] {ManagedObject.class});
|
||||
}
|
||||
|
||||
enhancer.setCallback(new MethodAccessTracker(path));
|
||||
|
||||
return (A) enhancer.create(argumentTypes, arguments);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user