Skip to content

Commit 3a3a8aa

Browse files
authored
Merge pull request #50 from AutomateThePlanet/smpInternal
Fixes in Grid component
2 parents 1fd313d + 0750880 commit 3a3a8aa

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
# macOS resource fork
1010
*.DS_Store
11-
.AppleDouble
1211
.LSOverride
12+
.AppleDouble
1313
.*.icloud
1414

1515
# Compiled class file

bellatrix.core/src/main/java/solutions/bellatrix/core/utilities/Wait.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static void retry(Runnable action, Duration sleepInterval, Duration timeo
7474

7575
public static void forMilliseconds(long millis) {
7676
try {
77+
Log.info("Waiting for %s milliseconds".formatted(millis));
7778
Thread.sleep(millis);
7879
} catch (InterruptedException e) {
7980
throw new RuntimeException(e);

bellatrix.core/src/main/java/solutions/bellatrix/core/utilities/parsing/GenericDateTimeParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static void prioritizePattern(String pattern) {
8282
FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX"));
8383
FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS"));
8484
FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
85+
FORMATTERS.add(DateTimeFormatter.ofPattern("dd.MM.yyyy, HH:mm"));
8586
}
8687

8788
public static LocalDateTime parse(String data) {

bellatrix.web/src/main/java/solutions/bellatrix/web/components/advanced/grid/Grid.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import solutions.bellatrix.web.findstrategies.XPathFindStrategy;
2424

2525
import java.lang.reflect.Field;
26+
import java.lang.reflect.InvocationTargetException;
2627
import java.lang.reflect.Method;
2728
import java.util.*;
2829
import java.util.function.Consumer;
@@ -284,7 +285,6 @@ public <TRowObject> void assertTable(Class<TRowObject> clazz, List<TRowObject> e
284285
}
285286
}
286287

287-
@SneakyThrows
288288
@SuppressWarnings({"unchecked"})
289289
public <TRowObject> void assertTable(Class<TRowObject> clazz, List<TRowObject> expectedEntities) {
290290
scrollToVisible();
@@ -308,8 +308,13 @@ public <TRowObject> void assertTable(Class<TRowObject> clazz, List<TRowObject> e
308308
if (!clazz.equals(Object.class)) {
309309
entity = castRow(clazz, i, propsNotToCompare);
310310
} else {
311-
Method method = this.getClass().getMethod("castRow", int.class, List.class);
312-
entity = (TRowObject)method.invoke(this, i, Arrays.stream(propsNotToCompare).toList());
311+
Method method = null;
312+
try {
313+
method = this.getClass().getMethod("castRow", int.class, List.class);
314+
entity = (TRowObject)method.invoke(this, i, Arrays.stream(propsNotToCompare).toList());
315+
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
316+
throw new RuntimeException(e);
317+
}
313318
}
314319
EntitiesAsserter.areEqual(expectedEntities.get(i), entity, propsNotToCompare);
315320
}
@@ -353,10 +358,10 @@ public <TRowObject> TRowObject castRow(Class<TRowObject> clazz, int rowIndex, St
353358
}
354359

355360
var dto = InstanceFactory.create(clazz);
356-
var fields = clazz.getFields();
361+
var fields = clazz.getDeclaredFields();
357362
for (var field : fields) {
358363
var fieldType = field.getType();
359-
364+
field.setAccessible(true);
360365
var headerInfo = getHeaderNamesService().getHeaderInfoByField(field);
361366

362367
if (Arrays.stream(fieldsToSkip).anyMatch(f -> f.equals(headerInfo.getHeaderName()))) continue;
@@ -531,11 +536,21 @@ public <TComponent extends WebComponent, TFindStrategy extends FindStrategy> Gri
531536

532537
public <TGridModel> Grid setModelColumns(Class<TGridModel> clazz) {
533538
controlColumnDataCollection = new ArrayList<>();
534-
for (var field : clazz.getFields()) {
539+
List<Field> declaredFields = List.of(clazz.getDeclaredFields());
540+
for (var field : declaredFields) {
541+
field.setAccessible(true);
535542
var headerName = field.isAnnotationPresent(TableHeader.class) ? field.getAnnotation(TableHeader.class).name() : field.getName();
536543
controlColumnDataCollection.add(new ControlColumnData(headerName));
537544
}
538545

539546
return this;
540547
}
548+
549+
private static String getFieldNameFromGetter(String getterName) {
550+
if (getterName.startsWith("get")) {
551+
String fieldName = getterName.substring(3); // Remove "get"
552+
return Character.toLowerCase(fieldName.charAt(0)) + fieldName.substring(1); // Lowercase the first character
553+
}
554+
return getterName;
555+
}
541556
}

bellatrix.web/src/main/java/solutions/bellatrix/web/services/BrowserService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ public List<LogEntry> getSevereLogEntries() {
209209
return logs;
210210
}
211211

212+
public List<String> getRequestEntries(String partialUrl) {
213+
return (List<String>)((JavascriptExecutor)getWrappedDriver()).executeScript(String.format("return window.performance.getEntriesByType('resource').filter(x => x.name.indexOf('%s') >= 0).map(y => y.name);", partialUrl));
214+
}
215+
212216
public void waitForAjax() {
213217
long ajaxTimeout = ConfigurationService.get(WebSettings.class).getTimeoutSettings().getWaitForAjaxTimeout();
214218
long sleepInterval = ConfigurationService.get(WebSettings.class).getTimeoutSettings().getSleepInterval();

0 commit comments

Comments
 (0)