Skip to content

Commit 7fd0c57

Browse files
committed
tests fixed for normal testnet account
1 parent c89c06c commit 7fd0c57

File tree

7 files changed

+144
-48
lines changed

7 files changed

+144
-48
lines changed

hedera-microprofile/pom.xml

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
<dependencies>
2323
<dependency>
2424
<groupId>org.eclipse.microprofile</groupId>
25-
<artifactId>microprofile-bom</artifactId>
26-
<version>1.1.0</version>
25+
<artifactId>microprofile</artifactId>
26+
<version>7.0</version>
27+
<scope>import</scope>
2728
<type>pom</type>
2829
</dependency>
2930
</dependencies>
@@ -38,74 +39,64 @@
3839
<dependency>
3940
<groupId>org.eclipse.microprofile.config</groupId>
4041
<artifactId>microprofile-config-api</artifactId>
41-
<version>3.1</version>
4242
<scope>provided</scope>
4343
</dependency>
4444
<dependency>
4545
<groupId>jakarta.enterprise</groupId>
4646
<artifactId>jakarta.enterprise.cdi-api</artifactId>
47-
<version>4.0.1</version>
47+
<version>3.0.1</version>
4848
<scope>provided</scope>
4949
</dependency>
5050
<dependency>
5151
<groupId>jakarta.json</groupId>
5252
<artifactId>jakarta.json-api</artifactId>
53-
<version>2.1.0</version>
5453
<scope>provided</scope>
5554
</dependency>
5655
<dependency>
5756
<groupId>jakarta.ws.rs</groupId>
5857
<artifactId>jakarta.ws.rs-api</artifactId>
59-
<version>3.1.0</version>
6058
<scope>provided</scope>
6159
</dependency>
60+
61+
<dependency>
62+
<groupId>io.helidon.microprofile.server</groupId>
63+
<artifactId>helidon-microprofile-server</artifactId>
64+
<version>3.2.10</version>
65+
<scope>test</scope>
66+
</dependency>
6267
<dependency>
63-
<groupId>io.quarkus</groupId>
64-
<artifactId>quarkus-arc</artifactId>
65-
<version>3.12.2</version>
68+
<groupId>io.helidon.microprofile.tests</groupId>
69+
<artifactId>helidon-microprofile-tests-junit5</artifactId>
70+
<version>3.2.10</version>
6671
<scope>test</scope>
6772
</dependency>
6873
<dependency>
69-
<groupId>io.quarkus</groupId>
70-
<artifactId>quarkus-junit5</artifactId>
71-
<version>3.12.2</version>
74+
<groupId>org.junit.jupiter</groupId>
75+
<artifactId>junit-jupiter</artifactId>
76+
<version>5.10.3</version>
7277
<scope>test</scope>
7378
</dependency>
7479
<dependency>
7580
<groupId>io.grpc</groupId>
7681
<artifactId>grpc-okhttp</artifactId>
77-
<version>1.64.0</version>
7882
<scope>test</scope>
7983
</dependency>
8084
<dependency>
8185
<groupId>io.grpc</groupId>
8286
<artifactId>grpc-inprocess</artifactId>
83-
<version>1.64.0</version>
87+
<scope>test</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>io.github.cdimascio</groupId>
91+
<artifactId>dotenv-java</artifactId>
92+
<scope>test</scope>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.slf4j</groupId>
96+
<artifactId>slf4j-simple</artifactId>
97+
<version>2.0.13</version>
8498
<scope>test</scope>
8599
</dependency>
86100
</dependencies>
87101

88-
<build>
89-
<plugins>
90-
<plugin>
91-
<groupId>org.apache.maven.plugins</groupId>
92-
<artifactId>maven-surefire-plugin</artifactId>
93-
<version>3.3.1</version>
94-
<configuration>
95-
<systemPropertyVariables>
96-
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
97-
<maven.home>${maven.home}</maven.home>
98-
</systemPropertyVariables>
99-
</configuration>
100-
</plugin>
101-
<plugin>
102-
<groupId>org.jreleaser</groupId>
103-
<artifactId>jreleaser-maven-plugin</artifactId>
104-
<configuration>
105-
<skip>true</skip>
106-
</configuration>
107-
</plugin>
108-
</plugins>
109-
</build>
110-
111102
</project>

hedera-microprofile/src/main/java/com/openelements/hedera/microprofile/ClientProvider.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,23 @@
1717
import com.openelements.hedera.microprofile.implementation.ContractVerificationClientImpl;
1818
import jakarta.enterprise.context.ApplicationScoped;
1919
import jakarta.enterprise.inject.Produces;
20+
import jakarta.inject.Inject;
2021
import java.util.Arrays;
2122
import java.util.Objects;
2223
import org.eclipse.microprofile.config.inject.ConfigProperty;
2324
import org.jspecify.annotations.NonNull;
2425

2526
public class ClientProvider {
2627

27-
@ConfigProperty(name = "hedera.newAccountId")
28+
@Inject
29+
@ConfigProperty(name = "hedera.accountId")
2830
private String accountIdAsString;
2931

32+
@Inject
3033
@ConfigProperty(name = "hedera.privateKey")
3134
private String privateKeyAsString;
3235

36+
@Inject
3337
@ConfigProperty(name = "hedera.network")
3438
private String network;
3539

@@ -50,7 +54,7 @@ private PrivateKey getPrivateKey() {
5054
}
5155

5256
private HederaNetwork getHederaNetwork() {
53-
if(Arrays.stream(HederaNetwork.values()).anyMatch(v -> Objects.equals(v.getName(), network))) {
57+
if (Arrays.stream(HederaNetwork.values()).anyMatch(v -> Objects.equals(v.getName(), network))) {
5458
try {
5559
return HederaNetwork.valueOf(network.toUpperCase());
5660
} catch (Exception e) {
@@ -66,7 +70,7 @@ private Client createClient() {
6670
final PrivateKey privateKey = getPrivateKey();
6771
final HederaNetwork hederaNetwork = getHederaNetwork();
6872
return Client.forName(hederaNetwork.getName())
69-
.setOperator(accountId, privateKey);
73+
.setOperator(accountId, privateKey);
7074
}
7175

7276
@Produces
@@ -84,7 +88,8 @@ FileClient createFileClient(@NonNull final ProtocolLayerClient protocolLayerClie
8488

8589
@Produces
8690
@ApplicationScoped
87-
SmartContractClient createSmartContractClient(@NonNull final ProtocolLayerClient protocolLayerClient, @NonNull final FileClient fileClient) {
91+
SmartContractClient createSmartContractClient(@NonNull final ProtocolLayerClient protocolLayerClient,
92+
@NonNull final FileClient fileClient) {
8893
return new SmartContractClientImpl(protocolLayerClient, fileClient);
8994
}
9095

@@ -96,7 +101,8 @@ AccountClient createAccountClient(@NonNull final ProtocolLayerClient protocolLay
96101

97102
@Produces
98103
@ApplicationScoped
99-
ContractVerificationClient createContractVerificationClient(@NonNull final ProtocolLayerClient protocolLayerClient, @NonNull final FileClient fileClient) {
104+
ContractVerificationClient createContractVerificationClient(@NonNull final ProtocolLayerClient protocolLayerClient,
105+
@NonNull final FileClient fileClient) {
100106
return new ContractVerificationClientImpl(getHederaNetwork());
101107
}
102108
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
4+
Copyright (C) 2016, 2017 Antonio Goncalves and others.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15+
implied.
16+
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
-->
21+
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
22+
bean-discovery-mode="annotated" version="1.1"
23+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"/>
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
package com.openelements.hedera.microprofile.test;
22

33
import com.openelements.hedera.base.FileClient;
4-
import io.quarkus.test.junit.QuarkusTest;
5-
import javax.inject.Inject;
4+
import com.openelements.hedera.microprofile.ClientProvider;
5+
import io.helidon.microprofile.tests.junit5.AddBean;
6+
import io.helidon.microprofile.tests.junit5.Configuration;
7+
import io.helidon.microprofile.tests.junit5.HelidonTest;
8+
import jakarta.inject.Inject;
9+
import org.eclipse.microprofile.config.Config;
10+
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
611
import org.junit.jupiter.api.Assertions;
7-
import org.junit.jupiter.api.Disabled;
12+
import org.junit.jupiter.api.BeforeAll;
813
import org.junit.jupiter.api.Test;
914

10-
//@QuarkusTest
15+
@HelidonTest
16+
@AddBean(ClientProvider.class)
17+
@Configuration(useExisting = true)
1118
public class FileClientTests {
1219

20+
@BeforeAll
21+
static void setup() {
22+
final Config build = ConfigProviderResolver.instance()
23+
.getBuilder().withSources(new TestConfigSource()).build();
24+
ConfigProviderResolver.instance().registerConfig(build, Thread.currentThread().getContextClassLoader());
25+
}
26+
1327
@Inject
1428
private FileClient fileClient;
1529

16-
//@Test
17-
void testFileClient() {
30+
@Test
31+
void testFileClient() throws Exception {
1832
Assertions.assertNotNull(fileClient);
33+
fileClient.createFile(new byte[0]);
1934
}
2035
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.openelements.hedera.microprofile.test;
2+
3+
import io.github.cdimascio.dotenv.Dotenv;
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
import java.util.Set;
7+
import org.eclipse.microprofile.config.spi.ConfigSource;
8+
9+
public class TestConfigSource implements ConfigSource {
10+
11+
private final Map<String, String> properties;
12+
13+
public TestConfigSource() {
14+
final Dotenv dotenv = Dotenv.load();
15+
properties = new HashMap<>();
16+
properties.put("mp.initializer.allow", "true");
17+
properties.put("mp.initializer.no-warn", "true");
18+
properties.put("hedera.accountId", dotenv.get("hedera.accountId"));
19+
properties.put("hedera.privateKey", dotenv.get("hedera.privateKey"));
20+
properties.put("hedera.network", dotenv.get("hedera.network"));
21+
}
22+
23+
@Override
24+
public Set<String> getPropertyNames() {
25+
return properties.keySet();
26+
}
27+
28+
@Override
29+
public String getValue(String propertyName) {
30+
return properties.get(propertyName);
31+
}
32+
33+
@Override
34+
public String getName() {
35+
return TestConfigSource.class.getName();
36+
}
37+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
4+
Copyright (C) 2016, 2017 Antonio Goncalves and others.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15+
implied.
16+
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
-->
21+
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
22+
bean-discovery-mode="annotated" version="1.1"
23+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.slf4j.simpleLogger.log.com.openelements=DEBUG

0 commit comments

Comments
 (0)