Skip to content

Commit dc7b881

Browse files
committed
Merge branch 'main' into bellatrix-jira-zephyr-plugin
# Conflicts: # bellatrix.core/src/main/java/solutions/bellatrix/core/plugins/PluginExecutionEngine.java # bellatrix.core/src/main/java/solutions/bellatrix/core/plugins/junit/BaseTest.java
2 parents 4b27d13 + b5b5c29 commit dc7b881

File tree

568 files changed

+14814
-667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

568 files changed

+14814
-667
lines changed

bellatrix.android/src/main/java/solutions/bellatrix/android/infrastructure/DriverService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.appium.java_client.remote.MobileCapabilityType;
2020
import lombok.SneakyThrows;
2121
import org.openqa.selenium.MutableCapabilities;
22-
import org.openqa.selenium.Platform;
2322
import org.openqa.selenium.remote.DesiredCapabilities;
2423
import solutions.bellatrix.android.configuration.AndroidSettings;
2524
import solutions.bellatrix.android.configuration.GridSettings;
@@ -30,11 +29,10 @@
3029

3130
import java.io.IOException;
3231
import java.io.InputStream;
33-
import java.net.MalformedURLException;
3432
import java.net.URL;
33+
import java.time.Duration;
3534
import java.util.HashMap;
3635
import java.util.Properties;
37-
import java.util.concurrent.TimeUnit;
3836

3937
public class DriverService {
4038
private static final ThreadLocal<Boolean> DISPOSED;
@@ -84,7 +82,7 @@ public static AndroidDriver start(AppConfiguration configuration) {
8482
driver = initializeDriverGridMode(gridSettings.get(), testName);
8583
}
8684

87-
driver.manage().timeouts().implicitlyWait(androidSettings.getTimeoutSettings().getImplicitWaitTimeout(), TimeUnit.SECONDS);
85+
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(androidSettings.getTimeoutSettings().getImplicitWaitTimeout()));
8886
WRAPPED_ANDROID_DRIVER.set(driver);
8987
solutions.bellatrix.web.infrastructure.DriverService.setWrappedDriver(driver);
9088
return driver;

bellatrix.core/pom.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<version>1.0</version>
2525

2626
<properties>
27-
<selenium.version>4.8.1</selenium.version>
27+
<selenium.version>4.11.0</selenium.version>
2828
<appium.version>8.3.0</appium.version>
2929
<testng.version>7.7.0</testng.version>
3030
<junit.version>5.9.2</junit.version>
@@ -62,19 +62,16 @@
6262
<groupId>software.amazon.awssdk</groupId>
6363
<artifactId>textract</artifactId>
6464
</dependency>
65-
6665
<dependency>
6766
<groupId>com.opencsv</groupId>
6867
<artifactId>opencsv</artifactId>
6968
<version>5.7.1</version>
7069
</dependency>
71-
7270
<dependency>
7371
<groupId>com.mailslurp</groupId>
7472
<artifactId>mailslurp-client-java</artifactId>
7573
<version>15.17.1</version>
7674
</dependency>
77-
7875
<dependency>
7976
<groupId>commons-io</groupId>
8077
<artifactId>commons-io</artifactId>
@@ -83,7 +80,7 @@
8380
<dependency>
8481
<groupId>com.google.guava</groupId>
8582
<artifactId>guava</artifactId>
86-
<version>31.1-jre</version>
83+
<version>33.0.0-jre</version>
8784
</dependency>
8885
<dependency>
8986
<groupId>com.google.code.gson</groupId>
@@ -166,5 +163,10 @@
166163
<artifactId>azure-identity</artifactId>
167164
<version>1.2.0</version>
168165
</dependency>
166+
<dependency>
167+
<groupId>org.jsoup</groupId>
168+
<artifactId>jsoup</artifactId>
169+
<version>1.17.2</version>
170+
</dependency>
169171
</dependencies>
170172
</project>

bellatrix.core/src/main/java/solutions/bellatrix/core/assertions/EntitiesAsserter.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,32 @@ private static <TEntity> List<Exception> assertAreEqualsInternal(TEntity expecte
6161
try {
6262
currentExpectedProperty = expectedObject.getClass().getMethod(currentRealProperty.getName());
6363
} catch (NoSuchMethodException e) {
64-
failedAssertions.add(e);
64+
System.out.println(String.format("Property %s not found.", currentRealProperty));
65+
// failedAssertions.add(e);
6566
}
6667

6768
var exceptionMessage = "The property " + currentRealProperty.getName() + " of class " + realObject.getClass().getSimpleName() + " was not as expected.";
6869

6970
try {
7071
if (currentRealProperty.getReturnType() == LocalDateTime.class) {
7172
LocalDateTimeAssert.areEqual(
72-
(LocalDateTime) currentExpectedProperty.invoke(expectedObject),
73-
(LocalDateTime) currentRealProperty.invoke(realObject),
73+
(LocalDateTime)currentExpectedProperty.invoke(expectedObject),
74+
(LocalDateTime)currentRealProperty.invoke(realObject),
7475
deltaType, deltaQuantity, exceptionMessage);
7576
} else {
7677
Assertions.assertEquals(
7778
currentExpectedProperty.invoke(expectedObject),
7879
currentRealProperty.invoke(realObject),
7980
exceptionMessage);
8081
}
81-
82-
} catch (Exception ex) {
82+
}
83+
catch (NoSuchMethodException nsm){
84+
//ignore this case
85+
}
86+
catch (NullPointerException nsmex){
87+
//ignore this case
88+
}
89+
catch (Exception ex) {
8390
failedAssertions.add(ex);
8491
}
8592
}

bellatrix.core/src/main/java/solutions/bellatrix/core/configuration/ConfigurationService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
public final class ConfigurationService {
3131
private static String environment;
3232

33+
public static String getEnvironment() {
34+
return environment;
35+
}
36+
3337
public static <T> T get(Class<T> configSection) {
3438
T mappedObject = (T)new Object();
3539
if (environment == null) {

bellatrix.core/src/main/java/solutions/bellatrix/core/integrations/azure/KeyVault.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

bellatrix.core/src/main/java/solutions/bellatrix/core/integrations/azure/SecretsResolver.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,10 @@ public static String getSecret(Supplier<String> getConfigValue) {
1010
return System.getenv(configValue.replace("env_", ""));
1111
}
1212

13-
if (configValue.startsWith("vault_")) {
14-
return KeyVault.getSecret(configValue.replace("vault_", ""));
15-
}
16-
1713
return configValue;
1814
}
1915

2016
public static String getSecret(String name) {
21-
if (KeyVault.isAvailable) {
22-
return KeyVault.getSecret(name);
23-
}
2417

2518
String environmentalVariable = System.getenv(name);
2619

bellatrix.core/src/main/java/solutions/bellatrix/core/plugins/PluginExecutionEngine.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
package solutions.bellatrix.core.plugins;
1515

1616
import java.lang.reflect.Method;
17-
import java.util.LinkedHashSet;
18-
import java.util.Set;
17+
import java.util.*;
1918

2019
public final class PluginExecutionEngine {
21-
private final static Set<Plugin> PLUGINS;
20+
private final static LinkedHashSet<Plugin> PLUGINS;
2221

2322
static {
2423
PLUGINS = new LinkedHashSet<>();
@@ -92,7 +91,7 @@ public static void preAfterTest(TestResult result, TimeRecord timeRecord, Method
9291
currentObserver.preAfterTest(result, timeRecord, memberInfo);
9392
}
9493
}
95-
94+
9695
/**
9796
* Deprecated. <br>
9897
* Use {@link #postAfterTest(TestResult, TimeRecord, Method, Throwable)} as it offers more information about the test.

bellatrix.core/src/main/java/solutions/bellatrix/core/plugins/junit/BaseTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414
package solutions.bellatrix.core.plugins.junit;
1515

16-
import org.junit.jupiter.api.AfterAll;
17-
import org.junit.jupiter.api.AfterEach;
18-
import org.junit.jupiter.api.BeforeEach;
19-
import org.junit.jupiter.api.TestInfo;
16+
import org.junit.jupiter.api.*;
2017
import org.junit.jupiter.api.extension.ExtendWith;
2118
import solutions.bellatrix.core.plugins.PluginExecutionEngine;
2219
import solutions.bellatrix.core.plugins.TestResult;
@@ -29,6 +26,7 @@
2926
import java.util.List;
3027

3128
@ExtendWith(TestResultWatcher.class)
29+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
3230
@ExtendWith(TestDurationWatcher.class)
3331
public class BaseTest extends UsesPlugins {
3432
static final ThreadLocal<TestResult> CURRENT_TEST_RESULT = new ThreadLocal<>();
@@ -95,7 +93,7 @@ public void afterMethodCore(TestInfo testInfo) {
9593
try {
9694
var testClass = this.getClass();
9795
assert testInfo.getTestMethod().isPresent();
98-
var methodInfo = testClass.getMethod(testInfo.getTestMethod().get().getName());
96+
var methodInfo = testClass.getMethod(testInfo.getTestMethod().get().getName(), testInfo.getTestMethod().get().getParameterTypes());
9997
PluginExecutionEngine.preAfterTest(CURRENT_TEST_RESULT.get(), methodInfo); // DEPRECATED, LEFT FOR COMPATIBILITY
10098
PluginExecutionEngine.preAfterTest(CURRENT_TEST_RESULT.get(), CURRENT_TEST_TIME_RECORD.get(), methodInfo);
10199
afterEach();
@@ -107,11 +105,12 @@ public void afterMethodCore(TestInfo testInfo) {
107105
}
108106

109107
@AfterAll
110-
public static void afterClassCore(TestInfo testInfo) {
108+
public void afterClassCore(TestInfo testInfo) {
111109
try {
112110
var testClass = testInfo.getTestClass();
113111
if (testClass.isPresent()) {
114112
PluginExecutionEngine.preAfterClass(testClass.get());
113+
afterClass();
115114
PluginExecutionEngine.postAfterClass(testClass.get());
116115
}
117116
} catch (Exception e) {
@@ -138,4 +137,7 @@ protected void onBeforeEachFailure() {
138137

139138
protected void afterEach() {
140139
}
140+
141+
protected void afterClass() {
142+
}
141143
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package solutions.bellatrix.core.utilities;
2+
3+
import java.awt.*;
4+
import java.awt.datatransfer.*;
5+
import java.io.IOException;
6+
7+
public class ClipboardManager {
8+
private static final Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
9+
10+
public static String getLastEntity() {
11+
var lastCopiedEntity = "";
12+
13+
try {
14+
lastCopiedEntity = (String)systemClipboard.getData(DataFlavor.stringFlavor);
15+
} catch (IOException | UnsupportedFlavorException e) {
16+
throw new RuntimeException(e);
17+
}
18+
19+
return lastCopiedEntity;
20+
}
21+
22+
public static void copyTextToClipboard(String text) {
23+
Transferable transferable = new StringSelection(text);
24+
systemClipboard.setContents(transferable, null);
25+
}
26+
}

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1+
/*
2+
* Copyright 2024 Automate The Planet Ltd.
3+
* Author: Miriam Kyoseva
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* You may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
114
package solutions.bellatrix.core.utilities;
215

316
import lombok.SneakyThrows;
417

18+
import java.lang.reflect.Field;
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
522
public class ConverterService {
623
public static <SourceT, ResultT> ResultT convert(SourceT source, int index) {
724
ResultT object = InstanceFactory.createByTypeParameter(source.getClass(), index);
825

26+
assert object != null;
927
return convert(source, object);
1028
}
1129

30+
@SuppressWarnings("unchecked")
1231
public static <SourceT, ResultT> ResultT convert(SourceT source, ResultT result) {
1332
var object = (ResultT) InstanceFactory.create(result.getClass());
1433

@@ -38,8 +57,8 @@ public static <SourceT, ResultT> ResultT convert(SourceT source, ResultT result)
3857
public static <SourceT, ResultT> ResultT convertToClass(SourceT source, Class<ResultT> result) {
3958
var object = (ResultT) InstanceFactory.create(result);
4059

41-
var sourceFields = source.getClass().getDeclaredFields();
42-
var objectFields = object.getClass().getDeclaredFields();
60+
List<Field> sourceFields = getAllFields(source.getClass());
61+
List<Field> objectFields = getAllFields(object.getClass());
4362

4463
for (var sourceField : sourceFields) {
4564
for (var objectField : objectFields) {
@@ -55,4 +74,19 @@ public static <SourceT, ResultT> ResultT convertToClass(SourceT source, Class<Re
5574

5675
return object;
5776
}
77+
78+
private static List<Field> getAllFields(Class<?> clazz) {
79+
List<Field> fields = new ArrayList<>();
80+
Class<?> currentClass = clazz;
81+
82+
while (currentClass != null) {
83+
var declaredFields = currentClass.getDeclaredFields();
84+
for (Field field : declaredFields) {
85+
fields.add(field);
86+
}
87+
currentClass = currentClass.getSuperclass();
88+
}
89+
90+
return fields;
91+
}
5892
}

0 commit comments

Comments
 (0)