From d1b828f5f520d9d52dd89227280f0e507b55766f Mon Sep 17 00:00:00 2001 From: Hendrik Ebbers Date: Mon, 17 Apr 2023 13:01:54 +0200 Subject: [PATCH 1/6] converter for all needed types Signed-off-by: Hendrik Ebbers --- hedera-node/hedera-app-spi/build.gradle.kts | 47 +- .../AbstractEnumConfigConverter.java | 38 ++ .../config/converter/AccountIDConverter.java | 56 +++ .../config/converter/ContractIDConverter.java | 56 +++ .../spi/config/converter/FileIDConverter.java | 55 +++ .../HederaFunctionalityConverter.java | 34 ++ .../config/converter/ProfileConverter.java | 46 ++ .../converter/SidecarTypeConverter.java | 32 ++ .../src/main/java/module-info.java | 1 + .../AbstractEnumConfigConverterTest.java | 111 +++++ .../converter/AccountIDConverterTest.java | 99 ++++ .../converter/ContractIDConverterTest.java | 99 ++++ .../config/converter/FileIDConverterTest.java | 100 ++++ .../HederaFunctionalityConverterTest.java | 59 +++ .../converter/ProfileConverterTest.java | 67 +++ .../converter/SidecarTypeConverterTest.java | 60 +++ .../node/app/config/converter/ClassCheck.java | 25 + .../CongestionMultipliersConverter.java | 33 ++ .../EntityScaleFactorsConverter.java | 33 ++ .../config/converter/EntityTypeConverter.java | 33 ++ .../converter/KnownBlockValuesConverter.java | 33 ++ .../LegacyContractIdActivationsConverter.java | 33 ++ .../converter/MapAccessTypeConverter.java | 32 ++ .../converter/RecomputeTypeConverter.java | 33 ++ .../converter/ScaleFactorConverter.java | 34 ++ .../PropertySourceBasedConfigSource.java | 48 ++ .../config/PropertySourceBasedConfigTest.java | 161 +++++++ .../CongestionMultipliersConverterTest.java | 62 +++ .../EntityScaleFactorsConverterTest.java | 73 +++ .../converter/EntityTypeConverterTest.java | 60 +++ .../KnownBlockValuesConverterTest.java | 63 +++ ...acyContractIdActivationsConverterTest.java | 66 +++ .../converter/MapAccessTypeConverterTest.java | 59 +++ .../converter/RecomputeTypeConverterTest.java | 59 +++ .../converter/ScaleFactorConverterTest.java | 63 +++ .../PropertySourceBasedConfigSourceTest.java | 63 +++ settings.gradle.kts | 452 +++++++++--------- 37 files changed, 2230 insertions(+), 248 deletions(-) create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java create mode 100644 hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java create mode 100644 hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java create mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java create mode 100644 hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java diff --git a/hedera-node/hedera-app-spi/build.gradle.kts b/hedera-node/hedera-app-spi/build.gradle.kts index fe6a8e96c6b0..64ff6f83887d 100644 --- a/hedera-node/hedera-app-spi/build.gradle.kts +++ b/hedera-node/hedera-app-spi/build.gradle.kts @@ -15,38 +15,39 @@ */ plugins { - id("com.hedera.hashgraph.conventions") - `java-test-fixtures` + id("com.hedera.hashgraph.conventions") + `java-test-fixtures` } description = "Hedera Application - SPI" configurations.all { - exclude("javax.annotation", "javax.annotation-api") - exclude("com.google.code.findbugs", "jsr305") - exclude("org.jetbrains", "annotations") - exclude("org.checkerframework", "checker-qual") + exclude("javax.annotation", "javax.annotation-api") + exclude("com.google.code.findbugs", "jsr305") + exclude("org.jetbrains", "annotations") + exclude("org.checkerframework", "checker-qual") - exclude("io.grpc", "grpc-core") - exclude("io.grpc", "grpc-context") - exclude("io.grpc", "grpc-api") - exclude("io.grpc", "grpc-testing") + exclude("io.grpc", "grpc-core") + exclude("io.grpc", "grpc-context") + exclude("io.grpc", "grpc-api") + exclude("io.grpc", "grpc-testing") } dependencies { - implementation(libs.swirlds.virtualmap) - implementation(libs.swirlds.jasperdb) - implementation(libs.swirlds.common) - api(libs.pbj.runtime) - api(libs.hapi) - api(libs.jsr305.annotation) - api(project(":hedera-node:hapi")) - compileOnlyApi(libs.spotbugs.annotations) + implementation(libs.swirlds.virtualmap) + implementation(libs.swirlds.jasperdb) + implementation(libs.swirlds.common) + api(libs.pbj.runtime) + api(libs.hapi) + api(libs.jsr305.annotation) + api(project(":hedera-node:hapi")) + compileOnlyApi(libs.spotbugs.annotations) - testImplementation(testLibs.bundles.testing) - testCompileOnly(libs.spotbugs.annotations) + testRuntimeOnly(libs.swirlds.config.impl) + testImplementation(testLibs.bundles.testing) + testCompileOnly(libs.spotbugs.annotations) - testFixturesCompileOnly(libs.spotbugs.annotations) - testFixturesCompileOnly(testLibs.assertj.core) - testFixturesApi(libs.swirlds.common) + testFixturesCompileOnly(libs.spotbugs.annotations) + testFixturesCompileOnly(testLibs.assertj.core) + testFixturesApi(libs.swirlds.common) } diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java new file mode 100644 index 000000000000..749a63fe65aa --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.swirlds.config.api.converter.ConfigConverter; +import edu.umd.cs.findbugs.annotations.NonNull; +import java.util.Objects; + +public abstract class AbstractEnumConfigConverter> implements ConfigConverter { + + @Override + public E convert(final String value) throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + final Class enumType = getEnumType(); + Objects.requireNonNull(enumType, "enumType"); + return Enum.valueOf(enumType, value); + } + + @NonNull + protected abstract Class getEnumType(); +} diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java new file mode 100644 index 000000000000..8297ae6d9a14 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.hedera.hapi.node.base.AccountID; +import com.swirlds.config.api.converter.ConfigConverter; +import java.util.stream.Stream; + +public class AccountIDConverter implements ConfigConverter { + + @Override + public AccountID convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + try { + final long[] nums = Stream.of(value.split("[.]")).mapToLong(Long::parseLong).toArray(); + if (nums.length != 3) { + throw new IllegalArgumentException("Does not match pattern 'A.B.C'"); + } + if (nums[0] < 0) { + throw new IllegalArgumentException("Shared num of value is negative"); + } + if (nums[1] < 0) { + throw new IllegalArgumentException("Realm num of value is negative"); + } + if (nums[2] < 0) { + throw new IllegalArgumentException("Account num of value is negative"); + } + return AccountID.newBuilder() + .shardNum(nums[0]) + .realmNum(nums[1]) + .accountNum(nums[2]) + .build(); + } catch (final Exception e) { + throw new IllegalArgumentException( + "'" + value + "' can not be parsed to " + AccountID.class.getName(), e); + } + } +} diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java new file mode 100644 index 000000000000..98d6be0e5cfd --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.hedera.hapi.node.base.ContractID; +import com.swirlds.config.api.converter.ConfigConverter; +import java.util.stream.Stream; + +public class ContractIDConverter implements ConfigConverter { + + @Override + public ContractID convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + try { + final long[] nums = Stream.of(value.split("[.]")).mapToLong(Long::valueOf).toArray(); + if (nums.length != 3) { + throw new IllegalArgumentException("Does not match pattern 'A.B.C'"); + } + if (nums[0] < 0) { + throw new IllegalArgumentException("Shared num of value is negative"); + } + if (nums[1] < 0) { + throw new IllegalArgumentException("Realm num of value is negative"); + } + if (nums[2] < 0) { + throw new IllegalArgumentException("Account num of value is negative"); + } + return ContractID.newBuilder() + .shardNum(nums[0]) + .realmNum(nums[1]) + .contractNum(nums[2]) + .build(); + } catch (final Exception e) { + throw new IllegalArgumentException( + "'" + value + "' can not be parsed to " + ContractID.class.getName(), e); + } + } +} diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java new file mode 100644 index 000000000000..9370e98c666c --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.hedera.hapi.node.base.FileID; +import com.swirlds.config.api.converter.ConfigConverter; +import java.util.stream.Stream; + +public class FileIDConverter implements ConfigConverter { + + @Override + public FileID convert(final String value) throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + try { + final long[] nums = Stream.of(value.split("[.]")).mapToLong(Long::parseLong).toArray(); + if (nums.length != 3) { + throw new IllegalArgumentException("Does not match pattern 'A.B.C'"); + } + if (nums[0] < 0) { + throw new IllegalArgumentException("Shared num of value is negative"); + } + if (nums[1] < 0) { + throw new IllegalArgumentException("Realm num of value is negative"); + } + if (nums[2] < 0) { + throw new IllegalArgumentException("File num of value is negative"); + } + return FileID.newBuilder() + .shardNum(nums[0]) + .realmNum(nums[1]) + .fileNum(nums[2]) + .build(); + } catch (final Exception e) { + throw new IllegalArgumentException( + "'" + value + "' can not be parsed to " + FileID.class.getName(), e); + } + } +} diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java new file mode 100644 index 000000000000..9ff353f4d8d8 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.hedera.hapi.node.base.HederaFunctionality; +import com.swirlds.config.api.converter.ConfigConverter; + +/** + * Converter implementation for the config API to support {@link HederaFunctionality}. Based on + * https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter explicitly + */ +public class HederaFunctionalityConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + + @Override + protected Class getEnumType() { + return HederaFunctionality.class; + } +} diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java new file mode 100644 index 000000000000..955b0921bde0 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.hedera.node.app.spi.config.Profile; +import com.swirlds.config.api.converter.ConfigConverter; + +public class ProfileConverter implements ConfigConverter { + + @Override + public Profile convert(final String value) throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + + try { + final int i = Integer.parseInt(value); + if (i == 0) { + return Profile.DEV; + } else if (i == 1) { + return Profile.PROD; + } else if (i == 2) { + return Profile.TEST; + } + } catch (final Exception e) { + //ignore + } + + return Profile.valueOf(value.toUpperCase()); + } +} diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java new file mode 100644 index 000000000000..4732f0a66cad --- /dev/null +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import com.hedera.hapi.streams.SidecarType; +import com.swirlds.config.api.converter.ConfigConverter; +import edu.umd.cs.findbugs.annotations.NonNull; + +public class SidecarTypeConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + + @NonNull + @Override + protected Class getEnumType() { + return SidecarType.class; + } +} diff --git a/hedera-node/hedera-app-spi/src/main/java/module-info.java b/hedera-node/hedera-app-spi/src/main/java/module-info.java index e23c7951ded4..ad651fd3e3b6 100644 --- a/hedera-node/hedera-app-spi/src/main/java/module-info.java +++ b/hedera-node/hedera-app-spi/src/main/java/module-info.java @@ -17,4 +17,5 @@ exports com.hedera.node.app.spi.validation; exports com.hedera.node.app.spi.accounts; exports com.hedera.node.app.spi.info; + exports com.hedera.node.app.spi.config.converter; } diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java new file mode 100644 index 000000000000..b3fa9d332259 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.swirlds.common.config.sources.SimpleConfigSource; +import com.swirlds.config.api.Configuration; +import com.swirlds.config.api.ConfigurationBuilder; +import com.swirlds.config.api.converter.ConfigConverter; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; +import org.junit.jupiter.api.Test; + +class AbstractEnumConfigConverterTest { + + /** + * Based on https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter + * explicitly + */ + private static class RetentionPolicyConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + + @Override + protected Class getEnumType() { + return RetentionPolicy.class; + } + } + + /** + * Based on https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter + * explicitly + */ + private static class ElementTypeConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + + @Override + protected Class getEnumType() { + return ElementType.class; + } + } + + @Test + void testNullValue() { + //given + final RetentionPolicyConverter converter = new RetentionPolicyConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidValue() { + //given + final RetentionPolicyConverter converter = new RetentionPolicyConverter(); + + //then + assertThatThrownBy(() -> converter.convert("not-supported-value")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testValidValue() { + //given + final RetentionPolicyConverter converter = new RetentionPolicyConverter(); + + //when + final RetentionPolicy source = converter.convert("SOURCE"); + + //then + assertThat(source).isEqualTo(RetentionPolicy.SOURCE); + } + + @Test + void testIntegration() { + //given + final Configuration configuration = ConfigurationBuilder.create() + .withSource(new SimpleConfigSource("retention-policy", "SOURCE")) + .withSource(new SimpleConfigSource("element-type", "TYPE")) + .withConverter(new RetentionPolicyConverter()) + .withConverter(new ElementTypeConverter()) + .build(); + + //when + final RetentionPolicy source = configuration.getValue("retention-policy", RetentionPolicy.class); + final ElementType type = configuration.getValue("element-type", ElementType.class); + + //then + assertThat(source).isEqualTo(RetentionPolicy.SOURCE); + assertThat(type).isEqualTo(ElementType.TYPE); + } + + +} \ No newline at end of file diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java new file mode 100644 index 000000000000..1b400eb6d62f --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class AccountIDConverterTest { + + @Test + void testNullParam() { + //given + final AccountIDConverter converter = new AccountIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + @ParameterizedTest + @ValueSource(strings = {"", " ", " ", "a.b.b", + "1.b.c", "1.2.c", "a.2.3", + "1", "1.2", + ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4"}) + void testAllNotParseable(final String input) { + //given + final AccountIDConverter converter = new AccountIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(input)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + @Disabled + @ParameterizedTest + @ValueSource(strings = {"1.2.3.", "1.2.3.."}) + void testEdgeCasesForDiscussion(final String input) { + //given + final AccountIDConverter converter = new AccountIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(input)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testSimpleValue() { + //given + final AccountIDConverter converter = new AccountIDConverter(); + final String value = "1.2.3"; + + //when + final var result = converter.convert(value); + + //then + assertThat(result).isNotNull(); + assertThat(result.shardNum()).isEqualTo(1L); + assertThat(result.realmNum()).isEqualTo(2L); + assertThat(result.accountNum()).isEqualTo(3L); + } + + @Test + void testLongValues() { + //given + final AccountIDConverter converter = new AccountIDConverter(); + final String value = Long.MAX_VALUE + "." + Long.MAX_VALUE + ".0"; + + //when + final var result = converter.convert(value); + + //then + assertThat(result).isNotNull(); + assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); + assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); + assertThat(result.accountNum()).isEqualTo(0); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java new file mode 100644 index 000000000000..59de20fa7f82 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class ContractIDConverterTest { + + @Test + void testNullParam() { + //given + final ContractIDConverter converter = new ContractIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + @ParameterizedTest + @ValueSource(strings = {"", " ", " ", "a.b.b", + "1.b.c", "1.2.c", "a.2.3", + "1", "1.2", + ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4"}) + void testAllNotParseable(final String input) { + //given + final ContractIDConverter converter = new ContractIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(input)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + @Disabled + @ParameterizedTest + @ValueSource(strings = {"1.2.3.", "1.2.3.."}) + void testEdgeCasesForDiscussion(final String input) { + //given + final ContractIDConverter converter = new ContractIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(input)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testSimpleValue() { + //given + final ContractIDConverter converter = new ContractIDConverter(); + final String value = "1.2.3"; + + //when + final var result = converter.convert(value); + + //then + assertThat(result).isNotNull(); + assertThat(result.shardNum()).isEqualTo(1L); + assertThat(result.realmNum()).isEqualTo(2L); + assertThat(result.contractNum()).isEqualTo(3L); + } + + @Test + void testLongValues() { + //given + final ContractIDConverter converter = new ContractIDConverter(); + final String value = Long.MAX_VALUE + "." + Long.MAX_VALUE + ".0"; + + //when + final var result = converter.convert(value); + + //then + assertThat(result).isNotNull(); + assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); + assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); + assertThat(result.contractNum()).isEqualTo(0); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java new file mode 100644 index 000000000000..26f7f88308f1 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class FileIDConverterTest { + + @Test + void testNullParam() { + //given + final FileIDConverter converter = new FileIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + @ParameterizedTest + @ValueSource(strings = {"", " ", " ", "a.b.b", + "1.b.c", "1.2.c", "a.2.3", + "1", "1.2", + ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4"}) + void testAllNotParseable(final String input) { + //given + final FileIDConverter converter = new FileIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(input)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + @Disabled + @ParameterizedTest + @ValueSource(strings = {"1.2.3.", "1.2.3.."}) + void testEdgeCasesForDiscussion(final String input) { + //given + final FileIDConverter converter = new FileIDConverter(); + + //then + assertThatThrownBy(() -> converter.convert(input)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testSimpleValue() { + //given + final FileIDConverter converter = new FileIDConverter(); + final String value = "1.2.3"; + + //when + final var result = converter.convert(value); + + //then + assertThat(result).isNotNull(); + assertThat(result.shardNum()).isEqualTo(1L); + assertThat(result.realmNum()).isEqualTo(2L); + assertThat(result.fileNum()).isEqualTo(3L); + } + + @Test + void testLongValues() { + //given + final FileIDConverter converter = new FileIDConverter(); + final String value = Long.MAX_VALUE + "." + Long.MAX_VALUE + ".0"; + + //when + final var result = converter.convert(value); + + //then + assertThat(result).isNotNull(); + assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); + assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); + assertThat(result.fileNum()).isEqualTo(0); + } + +} \ No newline at end of file diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java new file mode 100644 index 000000000000..92ce0c0276f5 --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.hapi.node.base.HederaFunctionality; +import org.junit.jupiter.api.Test; + +class HederaFunctionalityConverterTest { + + @Test + void testNullParam() { + //given + final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidParam() { + //given + final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testValidParam() { + //given + final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); + + //when + final HederaFunctionality cryptoTransfer = converter.convert("CRYPTO_TRANSFER"); + + //then + assertThat(cryptoTransfer).isEqualTo(HederaFunctionality.CRYPTO_TRANSFER); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java new file mode 100644 index 000000000000..a56b89b32ded --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.spi.config.Profile; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class ProfileConverterTest { + + @Test + void testNullParam() { + //given + final ProfileConverter converter = new ProfileConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidParam() { + //given + final ProfileConverter converter = new ProfileConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + @ParameterizedTest + @CsvSource({"DEV, DEV", "TEST, TEST", "PROD, PROD", + "dev, DEV", "test, TEST", "prod, PROD", + "dEv, DEV", "tEst, TEST", "pRod, PROD", + "0,DEV", "2,TEST", "1,PROD"}) + void testValidParam(final String input, final String enumName) { + //given + final ProfileConverter converter = new ProfileConverter(); + final Profile expected = Profile.valueOf(enumName); + + //when + final Profile cryptoTransfer = converter.convert(input); + + //then + assertThat(cryptoTransfer).isEqualTo(expected); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java new file mode 100644 index 000000000000..7fe8327f088f --- /dev/null +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.spi.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.hapi.streams.SidecarType; +import org.junit.jupiter.api.Test; + +class SidecarTypeConverterTest { + + @Test + void testNullParam() { + //given + final SidecarTypeConverter converter = new SidecarTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidParam() { + //given + final SidecarTypeConverter converter = new SidecarTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testValidParam() { + //given + final SidecarTypeConverter converter = new SidecarTypeConverter(); + + //when + final SidecarType sidecarType = converter.convert("SIDECAR_TYPE_UNKNOWN"); + + //then + assertThat(sidecarType).isEqualTo(SidecarType.SIDECAR_TYPE_UNKNOWN); + } + +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java new file mode 100644 index 000000000000..50504f953848 --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +public class ClassCheck { + + void foo() { + + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java new file mode 100644 index 000000000000..dd9ed466cb7d --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.service.mono.fees.calculation.CongestionMultipliers; +import com.swirlds.config.api.converter.ConfigConverter; + +public class CongestionMultipliersConverter implements ConfigConverter { + + @Override + public CongestionMultipliers convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + return CongestionMultipliers.from(value); + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java new file mode 100644 index 000000000000..1c3168e0f4dc --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.service.mono.fees.calculation.EntityScaleFactors; +import com.swirlds.config.api.converter.ConfigConverter; + +public class EntityScaleFactorsConverter implements ConfigConverter { + + @Override + public EntityScaleFactors convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + return EntityScaleFactors.from(value); + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java new file mode 100644 index 000000000000..86d7ccb6017c --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.service.mono.context.properties.EntityType; +import com.hedera.node.app.spi.config.converter.AbstractEnumConfigConverter; +import com.swirlds.config.api.converter.ConfigConverter; +import edu.umd.cs.findbugs.annotations.NonNull; + +public class EntityTypeConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + + @NonNull + @Override + protected Class getEnumType() { + return EntityType.class; + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java new file mode 100644 index 000000000000..c8396670370d --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.hapi.utils.sysfiles.domain.KnownBlockValues; +import com.swirlds.config.api.converter.ConfigConverter; + +public class KnownBlockValuesConverter implements ConfigConverter { + + @Override + public KnownBlockValues convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + return KnownBlockValues.from(value); + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java new file mode 100644 index 000000000000..42a6d7010dd6 --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.service.mono.keys.LegacyContractIdActivations; +import com.swirlds.config.api.converter.ConfigConverter; + +public class LegacyContractIdActivationsConverter implements ConfigConverter { + + @Override + public LegacyContractIdActivations convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + return LegacyContractIdActivations.from(value); + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java new file mode 100644 index 000000000000..a57443524eb2 --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.service.mono.throttling.MapAccessType; +import com.hedera.node.app.spi.config.converter.AbstractEnumConfigConverter; +import com.swirlds.config.api.converter.ConfigConverter; +import edu.umd.cs.findbugs.annotations.NonNull; + +public class MapAccessTypeConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + @NonNull + @Override + protected Class getEnumType() { + return MapAccessType.class; + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java new file mode 100644 index 000000000000..627572f1031e --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.service.mono.ledger.accounts.staking.StakeStartupHelper.RecomputeType; +import com.hedera.node.app.spi.config.converter.AbstractEnumConfigConverter; +import com.swirlds.config.api.converter.ConfigConverter; +import edu.umd.cs.findbugs.annotations.NonNull; + +public class RecomputeTypeConverter extends AbstractEnumConfigConverter implements + ConfigConverter { + + @NonNull + @Override + protected Class getEnumType() { + return RecomputeType.class; + } +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java new file mode 100644 index 000000000000..37811eac8895 --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import com.hedera.node.app.hapi.utils.sysfiles.domain.throttling.ScaleFactor; +import com.swirlds.config.api.converter.ConfigConverter; + +public class ScaleFactorConverter implements ConfigConverter { + + @Override + public ScaleFactor convert(final String value) + throws IllegalArgumentException, NullPointerException { + if (value == null) { + throw new NullPointerException("null can not be converted"); + } + return ScaleFactor.from(value); + } + +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java new file mode 100644 index 000000000000..9154b7c97cbb --- /dev/null +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.source; + +import com.hedera.node.app.service.mono.context.properties.PropertySource; +import com.swirlds.config.api.source.ConfigSource; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +public class PropertySourceBasedConfigSource implements ConfigSource { + + private final PropertySource propertySource; + + public PropertySourceBasedConfigSource( + @NonNull final PropertySource propertySource) { + this.propertySource = Objects.requireNonNull(propertySource, "propertySource"); + } + + @Override + @NonNull + public Set getPropertyNames() { + return propertySource.allPropertyNames(); + } + + @Override + @Nullable + public String getValue(@NonNull final String name) throws NoSuchElementException { + return propertySource.getRawValue(name); + } +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java new file mode 100644 index 000000000000..417155fd0c7d --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.hedera.hapi.node.base.AccountID; +import com.hedera.hapi.node.base.ContractID; +import com.hedera.hapi.node.base.FileID; +import com.hedera.hapi.node.base.HederaFunctionality; +import com.hedera.hapi.streams.SidecarType; +import com.hedera.node.app.config.converter.CongestionMultipliersConverter; +import com.hedera.node.app.config.converter.EntityScaleFactorsConverter; +import com.hedera.node.app.config.converter.EntityTypeConverter; +import com.hedera.node.app.config.converter.KnownBlockValuesConverter; +import com.hedera.node.app.config.converter.LegacyContractIdActivationsConverter; +import com.hedera.node.app.config.converter.MapAccessTypeConverter; +import com.hedera.node.app.config.converter.RecomputeTypeConverter; +import com.hedera.node.app.config.converter.ScaleFactorConverter; +import com.hedera.node.app.config.source.PropertySourceBasedConfigSource; +import com.hedera.node.app.hapi.utils.sysfiles.domain.KnownBlockValues; +import com.hedera.node.app.hapi.utils.sysfiles.domain.throttling.ScaleFactor; +import com.hedera.node.app.service.mono.context.properties.EntityType; +import com.hedera.node.app.service.mono.context.properties.PropertySource; +import com.hedera.node.app.service.mono.fees.calculation.CongestionMultipliers; +import com.hedera.node.app.service.mono.fees.calculation.EntityScaleFactors; +import com.hedera.node.app.service.mono.keys.LegacyContractIdActivations; +import com.hedera.node.app.service.mono.ledger.accounts.staking.StakeStartupHelper.RecomputeType; +import com.hedera.node.app.service.mono.throttling.MapAccessType; +import com.hedera.node.app.spi.config.Profile; +import com.hedera.node.app.spi.config.converter.AccountIDConverter; +import com.hedera.node.app.spi.config.converter.ContractIDConverter; +import com.hedera.node.app.spi.config.converter.FileIDConverter; +import com.hedera.node.app.spi.config.converter.HederaFunctionalityConverter; +import com.hedera.node.app.spi.config.converter.ProfileConverter; +import com.hedera.node.app.spi.config.converter.SidecarTypeConverter; +import com.swirlds.config.api.Configuration; +import com.swirlds.config.api.ConfigurationBuilder; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.BDDMockito; +import org.mockito.Mock; +import org.mockito.Mock.Strictness; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class PropertySourceBasedConfigTest { + + @Mock(strictness = Strictness.LENIENT) + private PropertySource propertySource; + + private final Map rawData = new HashMap<>(); + + @BeforeEach + void configureMockForConfigData() { + rawData.put("test.congestionMultipliers", "90,11x,95,27x,99,103x"); + rawData.put("test.entityScaleFactors", "DEFAULT(32,7:1)"); + rawData.put("test.entityType", "CONTRACT"); + rawData.put("test.knownBlockValues", "c9e37a7a454638ca62662bd1a06de49ef40b3444203fe329bbc81363604ea7f8@666"); + rawData.put("test.legacyContractIdActivations", "1058134by[1062784|2173895],857111by[522000|365365]"); + rawData.put("test.mapAccessType", "ACCOUNTS_GET"); + rawData.put("test.recomputeType", "PENDING_REWARDS"); + rawData.put("test.scaleFactor", "1:3"); + rawData.put("test.accountID", "1.2.3"); + rawData.put("test.contractID", "1.2.3"); + rawData.put("test.fileID", "1.2.3"); + rawData.put("test.hederaFunctionality", "CRYPTO_TRANSFER"); + rawData.put("test.profile", "DEV"); + rawData.put("test.sidecarType", "CONTRACT_ACTION"); + + BDDMockito.given(propertySource.allPropertyNames()).willReturn(rawData.keySet()); + rawData.forEach((key, value) -> BDDMockito.given(propertySource.getRawValue(key)).willReturn(value)); + } + + @Test + public void testConfig() { + //given + final Configuration configuration = ConfigurationBuilder.create() + .withConverter(new CongestionMultipliersConverter()) + .withConverter(new EntityScaleFactorsConverter()) + .withConverter(new EntityTypeConverter()) + .withConverter(new KnownBlockValuesConverter()) + .withConverter(new LegacyContractIdActivationsConverter()) + .withConverter(new MapAccessTypeConverter()) + .withConverter(new RecomputeTypeConverter()) + .withConverter(new ScaleFactorConverter()) + .withConverter(new AccountIDConverter()) + .withConverter(new ContractIDConverter()) + .withConverter(new FileIDConverter()) + .withConverter(new HederaFunctionalityConverter()) + .withConverter(new ProfileConverter()) + .withConverter(new SidecarTypeConverter()) + .withSource(new PropertySourceBasedConfigSource(propertySource)) + .build(); + + //when + final CongestionMultipliers congestionMultipliers = configuration.getValue("test.congestionMultipliers", + CongestionMultipliers.class); + final EntityScaleFactors entityScaleFactors = configuration.getValue("test.entityScaleFactors", + EntityScaleFactors.class); + final EntityType entityType = configuration.getValue("test.entityType", + EntityType.class); + final KnownBlockValues knownBlockValues = configuration.getValue("test.knownBlockValues", + KnownBlockValues.class); + final LegacyContractIdActivations legacyContractIdActivations = configuration.getValue( + "test.legacyContractIdActivations", + LegacyContractIdActivations.class); + final MapAccessType mapAccessType = configuration.getValue("test.mapAccessType", + MapAccessType.class); + final RecomputeType recomputeType = configuration.getValue("test.recomputeType", + RecomputeType.class); + final ScaleFactor scaleFactor = configuration.getValue("test.scaleFactor", + ScaleFactor.class); + final AccountID accountID = configuration.getValue("test.accountID", + AccountID.class); + final ContractID contractID = configuration.getValue("test.contractID", + ContractID.class); + final FileID fileID = configuration.getValue("test.fileID", + FileID.class); + final HederaFunctionality hederaFunctionality = configuration.getValue("test.hederaFunctionality", + HederaFunctionality.class); + final Profile profile = configuration.getValue("test.profile", + Profile.class); + final SidecarType sidecarType = configuration.getValue("test.sidecarType", + SidecarType.class); + + //then + assertThat(congestionMultipliers).isNotNull(); + assertThat(entityScaleFactors).isNotNull(); + assertThat(entityType).isNotNull(); + assertThat(knownBlockValues).isNotNull(); + assertThat(legacyContractIdActivations).isNotNull(); + assertThat(mapAccessType).isNotNull(); + assertThat(recomputeType).isNotNull(); + assertThat(scaleFactor).isNotNull(); + assertThat(accountID).isNotNull(); + assertThat(contractID).isNotNull(); + assertThat(fileID).isNotNull(); + assertThat(hederaFunctionality).isNotNull(); + assertThat(profile).isNotNull(); + assertThat(sidecarType).isNotNull(); + } +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java new file mode 100644 index 000000000000..01dd8afb51b6 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.service.mono.fees.calculation.CongestionMultipliers; +import org.junit.jupiter.api.Test; + +class CongestionMultipliersConverterTest { + + @Test + void testNullValue() { + //given + final CongestionMultipliersConverter converter = new CongestionMultipliersConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testValidValue() { + //given + final CongestionMultipliersConverter converter = new CongestionMultipliersConverter(); + final String input = "90,10x,95,25x,99,100x"; + + //when + final CongestionMultipliers multipliers = converter.convert(input); + + //then + assertThat(multipliers).isNotNull(); + assertThat(multipliers.usagePercentTriggers()).containsExactly(90, 95, 99); + assertThat(multipliers.multipliers()).containsExactly(10L, 25L, 100L); + } + + @Test + void testInvalidValue() { + //given + final CongestionMultipliersConverter converter = new CongestionMultipliersConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java new file mode 100644 index 000000000000..a5add3e2cfe9 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.hapi.utils.sysfiles.domain.throttling.ScaleFactor; +import com.hedera.node.app.service.mono.fees.calculation.EntityScaleFactors; +import org.junit.jupiter.api.Test; + +class EntityScaleFactorsConverterTest { + + @Test + void testNullValue() { + //given + final EntityScaleFactorsConverter converter = new EntityScaleFactorsConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testValidValue() { + //given + final EntityScaleFactorsConverter converter = new EntityScaleFactorsConverter(); + final String input = "DEFAULT(90,10:1,95,25:1,99,100:1)"; + + //when + final EntityScaleFactors entityScaleFactors = converter.convert(input); + + //then + assertThat(entityScaleFactors).isNotNull(); + assertThat(entityScaleFactors.typeScaleFactors()).isEmpty(); + assertThat(entityScaleFactors.defaultScaleFactors()).isNotNull(); + assertThat(entityScaleFactors.defaultScaleFactors().usagePercentTriggers()).containsExactly(90, 95, 99); + assertThat(entityScaleFactors.defaultScaleFactors().scaleFactors()).containsExactly(ScaleFactor.from("10:1"), + ScaleFactor.from("25:1"), ScaleFactor.from("100:1")); + } + + @Test + void testEmptyValue() { + //given + final EntityScaleFactorsConverter converter = new EntityScaleFactorsConverter(); + final String input = ""; + + //when + final EntityScaleFactors entityScaleFactors = converter.convert(input); + + //then + assertThat(entityScaleFactors).isNotNull(); + assertThat(entityScaleFactors.typeScaleFactors()).isEmpty(); + assertThat(entityScaleFactors.defaultScaleFactors()).isNotNull(); + assertThat(entityScaleFactors.defaultScaleFactors().usagePercentTriggers()).containsExactly(0); + assertThat(entityScaleFactors.defaultScaleFactors().scaleFactors()).containsExactly(ScaleFactor.from("1:1")); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java new file mode 100644 index 000000000000..426fb26e3e6d --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.service.mono.context.properties.EntityType; +import org.junit.jupiter.api.Test; + +class EntityTypeConverterTest { + + @Test + void testNullParam() { + //given + final EntityTypeConverter converter = new EntityTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidParam() { + //given + final EntityTypeConverter converter = new EntityTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testValidParam() { + //given + final EntityTypeConverter converter = new EntityTypeConverter(); + + //when + final EntityType entityType = converter.convert("ACCOUNT"); + + //then + assertThat(entityType).isEqualTo(EntityType.ACCOUNT); + } + +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java new file mode 100644 index 000000000000..c9086f4a63a7 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.hapi.utils.sysfiles.domain.KnownBlockValues; +import org.junit.jupiter.api.Test; + +class KnownBlockValuesConverterTest { + + @Test + void testNullValue() { + //given + final KnownBlockValuesConverter converter = new KnownBlockValuesConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testValidValue() { + //given + final KnownBlockValuesConverter converter = new KnownBlockValuesConverter(); + final String input = "c9e37a7a454638ca62662bd1a06de49ef40b3444203fe329bbc81363604ea7f8@666"; + + //when + final KnownBlockValues knownBlockValues = converter.convert(input); + + //then + assertThat(knownBlockValues).isNotNull(); + assertThat(knownBlockValues.number()).isEqualTo(666L); + assertThat(knownBlockValues.hash()).asHexString() + .isEqualTo("C9E37A7A454638CA62662BD1A06DE49EF40B3444203FE329BBC81363604EA7F8"); + } + + @Test + void testInvalidValue() { + //given + final KnownBlockValuesConverter converter = new KnownBlockValuesConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java new file mode 100644 index 000000000000..f86286d08f15 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.service.mono.keys.LegacyContractIdActivations; +import java.util.Set; +import org.hyperledger.besu.datatypes.Address; +import org.junit.jupiter.api.Test; + +class LegacyContractIdActivationsConverterTest { + + @Test + void testNullValue() { + //given + final LegacyContractIdActivationsConverter converter = new LegacyContractIdActivationsConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testValidValue() { + //given + final LegacyContractIdActivationsConverter converter = new LegacyContractIdActivationsConverter(); + final String input = "1058134by[1062784]"; + + //when + final LegacyContractIdActivations contractIdActivations = converter.convert(input); + + //then + assertThat(contractIdActivations).isNotNull(); + assertThat(contractIdActivations.privilegedContracts()).hasSize(1) + .containsEntry( + Address.fromHexString("0x0000000000000000000000000000000000102556"), + Set.of(Address.fromHexString("0x0000000000000000000000000000000000103780"))); + } + + @Test + void testInvalidValue() { + //given + final LegacyContractIdActivationsConverter converter = new LegacyContractIdActivationsConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java new file mode 100644 index 000000000000..4febed89c416 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.service.mono.throttling.MapAccessType; +import org.junit.jupiter.api.Test; + +class MapAccessTypeConverterTest { + + @Test + void testNullParam() { + //given + final MapAccessTypeConverter converter = new MapAccessTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidParam() { + //given + final MapAccessTypeConverter converter = new MapAccessTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testValidParam() { + //given + final MapAccessTypeConverter converter = new MapAccessTypeConverter(); + + //when + final MapAccessType entityType = converter.convert("ACCOUNTS_GET"); + + //then + assertThat(entityType).isEqualTo(MapAccessType.ACCOUNTS_GET); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java new file mode 100644 index 000000000000..4f6cdfb9f22e --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.service.mono.ledger.accounts.staking.StakeStartupHelper.RecomputeType; +import org.junit.jupiter.api.Test; + +class RecomputeTypeConverterTest { + + @Test + void testNullParam() { + //given + final RecomputeTypeConverter converter = new RecomputeTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testInvalidParam() { + //given + final RecomputeTypeConverter converter = new RecomputeTypeConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testValidParam() { + //given + final RecomputeTypeConverter converter = new RecomputeTypeConverter(); + + //when + final RecomputeType entityType = converter.convert("NODE_STAKES"); + + //then + assertThat(entityType).isEqualTo(RecomputeType.NODE_STAKES); + } +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java new file mode 100644 index 000000000000..8b7665ac45b7 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.converter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.hapi.utils.sysfiles.domain.throttling.ScaleFactor; +import org.junit.jupiter.api.Test; + +class ScaleFactorConverterTest { + + @Test + void testNullValue() { + //given + final ScaleFactorConverter converter = new ScaleFactorConverter(); + + //then + assertThatThrownBy(() -> converter.convert(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testValidValue() { + //given + final ScaleFactorConverter converter = new ScaleFactorConverter(); + final String input = "1:3"; + + //when + final ScaleFactor scaleFactor = converter.convert(input); + + //then + assertThat(scaleFactor).isNotNull(); + assertThat(scaleFactor.numerator()).isEqualTo(1); + assertThat(scaleFactor.denominator()).isEqualTo(3); + } + + @Test + void testInvalidValue() { + //given + final ScaleFactorConverter converter = new ScaleFactorConverter(); + + //then + assertThatThrownBy(() -> converter.convert("null")) + .isInstanceOf(IllegalArgumentException.class); + } + +} \ No newline at end of file diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java new file mode 100644 index 000000000000..3b4d02592ad2 --- /dev/null +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.hedera.node.app.config.source; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.hedera.node.app.service.mono.context.properties.PropertySource; +import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.BDDMockito; +import org.mockito.Mock; +import org.mockito.Mock.Strictness; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PropertySourceBasedConfigSourceTest { + + @Mock(strictness = Strictness.LENIENT) + private PropertySource propertySource; + + @BeforeEach + void configureMockForConfigData() { + BDDMockito.given(propertySource.allPropertyNames()).willReturn(Set.of("a", "b", "c")); + BDDMockito.given(propertySource.getRawValue("a")).willReturn("result-a"); + BDDMockito.given(propertySource.getRawValue("b")).willReturn("result-b"); + BDDMockito.given(propertySource.getRawValue("c")).willReturn("result-c"); + } + + + @Test + void testNullParam() { + assertThatThrownBy(() -> new PropertySourceBasedConfigSource(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + void testUsageParam() { + final PropertySourceBasedConfigSource configSource = new PropertySourceBasedConfigSource(propertySource); + + assertThat(configSource.getPropertyNames()).hasSize(3).contains("a", "b", "c"); + assertThat(configSource.getValue("a")).isEqualTo("result-a"); + assertThat(configSource.getValue("b")).isEqualTo("result-b"); + assertThat(configSource.getValue("c")).isEqualTo("result-c"); + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 8775486d781f..c54dacfbe33f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,19 +18,19 @@ import me.champeau.gradle.igp.gitRepositories // Add local maven build directory to plugin repos pluginManagement { - repositories { - gradlePluginPortal() - mavenCentral() - mavenLocal() - maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } - } + repositories { + gradlePluginPortal() + mavenCentral() + mavenLocal() + maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } + } } plugins { - id("com.gradle.enterprise").version("3.11.4") - // Use GIT plugin to clone HAPI protobuf files - // See documentation https://melix.github.io/includegit-gradle-plugin/latest/index.html - id("me.champeau.includegit").version("0.1.6") + id("com.gradle.enterprise").version("3.11.4") + // Use GIT plugin to clone HAPI protobuf files + // See documentation https://melix.github.io/includegit-gradle-plugin/latest/index.html + id("me.champeau.includegit").version("0.1.6") } include(":hedera-node") @@ -87,227 +87,229 @@ include(":hedera-node:test-clients") // Enable Gradle Build Scan gradleEnterprise { - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" - } + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } } gitRepositories { - checkoutsDirectory.set(file(rootProject.projectDir.absolutePath + "/hedera-node/hapi/")) - include("hedera-protobufs") { - uri.set("https://github.com/hashgraph/hedera-protobufs.git") - // choose tag or branch of HAPI you would like to test with - // this looks for a tag in hedera-protobufs repo - // This version needs to match tha HAPI version below in versionCatalogs - tag.set("add-pbj-types-for-state") - // do not load project from repo - autoInclude.set(false) - } + checkoutsDirectory.set(file(rootProject.projectDir.absolutePath + "/hedera-node/hapi/")) + include("hedera-protobufs") { + uri.set("https://github.com/hashgraph/hedera-protobufs.git") + // choose tag or branch of HAPI you would like to test with + // this looks for a tag in hedera-protobufs repo + // This version needs to match tha HAPI version below in versionCatalogs + tag.set("add-pbj-types-for-state") + // do not load project from repo + autoInclude.set(false) + } } // Define the library catalogs available for projects to make use of dependencyResolutionManagement { - @Suppress("UnstableApiUsage") - versionCatalogs { - // The libs of this catalog are the **ONLY** ones that are authorized to be part of the runtime - // distribution. These libs can be depended on during compilation, or bundled as part of - // runtime. - create("libs") { - // The HAPI API version to use, this need to match the tag set on gitRepositories above - version("hapi-version", "0.37.0-services-SNAPSHOT") - - // Definition of version numbers for all libraries - version("pbj-version", "0.5.1") - version("besu-version", "22.10.1") - version("besu-native-version", "0.6.1") - version("bouncycastle-version", "1.70") - version("caffeine-version", "3.0.6") - version("eclipse-collections-version", "10.4.0") - version("commons-codec-version", "1.15") - version("commons-io-version", "2.11.0") - version("commons-collections4-version", "4.4") - version("commons-lang3-version", "3.12.0") - version("dagger-version", "2.42") - version("eddsa-version", "0.3.0") - version("grpc-version", "1.50.2") - version("guava-version", "31.1-jre") - version("headlong-version", "6.1.1") - version("helidon-version", "3.0.2") - version("jackson-version", "2.13.3") - version("javax-annotation-version", "1.3.2") - version("javax-inject-version", "1") - version("jetbrains-annotation-version", "16.0.2") - version("log4j-version", "2.17.2") - version("netty-version", "4.1.66.Final") - version("protobuf-java-version", "3.19.4") - version("slf4j-version", "2.0.3") - version("swirlds-version", "0.36.1") - version("tuweni-version", "2.2.0") - version("jna-version", "5.12.1") - version("jsr305-version", "3.0.2") - version("spotbugs-version", "4.7.3") - version("helidon-grpc-version", "3.0.2") - - plugin("pbj", "com.hedera.pbj.pbj-compiler").versionRef("pbj-version") - - // List of bundles provided for us. When applicable, favor using these over individual - // libraries. - // Use when you need to use Besu - bundle( - "besu", - listOf("besu-bls12-381", "besu-evm", "besu-datatypes", "besu-secp256k1", "tuweni-units")) - // Use when you need to use bouncy castle - bundle("bouncycastle", listOf("bouncycastle-bcprov-jdk15on", "bouncycastle-bcpkix-jdk15on")) - // Use when you need to make use of dependency injection. - bundle("di", listOf("javax-inject", "dagger-api")) - // Use when you need a grpc server - bundle("helidon", listOf("helidon-server", "helidon-grpc-server", "helidon-io-grpc")) - // Use when you need logging - bundle("logging", listOf("log4j-api", "log4j-core", "log4j-slf4j", "slf4j-api")) - // Use when you need to depend upon netty - bundle("netty", listOf("netty-handler", "netty-transport-native-epoll")) - // Use when you depend upon all or swirlds - bundle( - "swirlds", - listOf( - "swirlds-common", - "swirlds-platform-core", - "swirlds-fchashmap", - "swirlds-merkle", - "swirlds-fcqueue", - "swirlds-jasperdb", - "swirlds-virtualmap")) - - // Define the individual libraries - library("pbj-runtime", "com.hedera.pbj", "pbj-runtime").versionRef("pbj-version") - library("besu-bls12-381", "org.hyperledger.besu", "bls12-381") - .versionRef("besu-native-version") - library("besu-secp256k1", "org.hyperledger.besu", "secp256k1") - .versionRef("besu-native-version") - library("besu-evm", "org.hyperledger.besu", "evm").versionRef("besu-version") - library("besu-datatypes", "org.hyperledger.besu", "besu-datatypes").versionRef("besu-version") - library("bouncycastle-bcprov-jdk15on", "org.bouncycastle", "bcprov-jdk15on") - .versionRef("bouncycastle-version") - library("bouncycastle-bcpkix-jdk15on", "org.bouncycastle", "bcpkix-jdk15on") - .versionRef("bouncycastle-version") - library("caffeine", "com.github.ben-manes.caffeine", "caffeine") - .versionRef("caffeine-version") - library("eclipse-collections", "org.eclipse.collections", "eclipse-collections") - .versionRef("eclipse-collections-version") - library("commons-collections4", "org.apache.commons", "commons-collections4") - .versionRef("commons-collections4-version") - library("commons-codec", "commons-codec", "commons-codec").versionRef("commons-codec-version") - library("commons-io", "commons-io", "commons-io").versionRef("commons-io-version") - library("commons-lang3", "org.apache.commons", "commons-lang3") - .versionRef("commons-lang3-version") - library("dagger-api", "com.google.dagger", "dagger").versionRef("dagger-version") - library("dagger-compiler", "com.google.dagger", "dagger-compiler") - .versionRef("dagger-version") - library("eddsa", "net.i2p.crypto", "eddsa").versionRef("eddsa-version") - library("grpc-stub", "io.grpc", "grpc-stub").versionRef("grpc-version") - library("grpc-protobuf", "io.grpc", "grpc-protobuf").versionRef("grpc-version") - library("grpc-netty", "io.grpc", "grpc-netty").versionRef("grpc-version") - library("guava", "com.google.guava", "guava").versionRef("guava-version") - library("hapi", "com.hedera.hashgraph", "hedera-protobuf-java-api").versionRef("hapi-version") - library("headlong", "com.esaulpaugh", "headlong").versionRef("headlong-version") - library("helidon-server", "io.helidon.webserver", "helidon-webserver-http2") - .versionRef("helidon-version") - library("helidon-grpc-server", "io.helidon.grpc", "helidon-grpc-server") - .versionRef("helidon-version") - library("helidon-io-grpc", "io.helidon.grpc", "io.grpc").versionRef("helidon-version") - library("jackson", "com.fasterxml.jackson.core", "jackson-databind") - .versionRef("jackson-version") - library("javax-annotation", "javax.annotation", "javax.annotation-api") - .versionRef("javax-annotation-version") - library("javax-inject", "javax.inject", "javax.inject").versionRef("javax-inject-version") - library("jetbrains-annotation", "org.jetbrains", "annotations") - .versionRef("jetbrains-annotation-version") - library("jsr305-annotation", "com.google.code.findbugs", "jsr305") - .versionRef("jsr305-version") - library("log4j-api", "org.apache.logging.log4j", "log4j-api").versionRef("log4j-version") - library("log4j-core", "org.apache.logging.log4j", "log4j-core").versionRef("log4j-version") - library("log4j-slf4j", "org.apache.logging.log4j", "log4j-slf4j-impl") - .versionRef("log4j-version") - library("netty-transport-native-epoll", "io.netty", "netty-transport-native-epoll") - .versionRef("netty-version") - library("netty-handler", "io.netty", "netty-handler").versionRef("netty-version") - library("protobuf-java", "com.google.protobuf", "protobuf-java") - .versionRef("protobuf-java-version") - library("swirlds-common", "com.swirlds", "swirlds-common").versionRef("swirlds-version") - library("slf4j-api", "org.slf4j", "slf4j-api").versionRef("slf4j-version") - library("slf4j-simple", "org.slf4j", "slf4j-api").versionRef("slf4j-version") - library("swirlds-platform-core", "com.swirlds", "swirlds-platform-core") - .versionRef("swirlds-version") - library("swirlds-fchashmap", "com.swirlds", "swirlds-fchashmap").versionRef("swirlds-version") - library("swirlds-merkle", "com.swirlds", "swirlds-merkle").versionRef("swirlds-version") - library("swirlds-fcqueue", "com.swirlds", "swirlds-fcqueue").versionRef("swirlds-version") - library("swirlds-jasperdb", "com.swirlds", "swirlds-jasperdb").versionRef("swirlds-version") - library("swirlds-virtualmap", "com.swirlds", "swirlds-virtualmap") - .versionRef("swirlds-version") - library("tuweni-units", "org.apache.tuweni", "tuweni-units").versionRef("tuweni-version") - library("jna", "net.java.dev.jna", "jna").versionRef("jna-version") - library("spotbugs-annotations", "com.github.spotbugs", "spotbugs-annotations") - .versionRef("spotbugs-version") - } - - // The libs of this catalog can be used for test or build uses. - create("testLibs") { - version("awaitility-version", "4.2.0") - version("besu-internal-version", "22.1.1") - version("commons-collections4-version", "4.4") - version("hamcrest-version", "2.2") - version("json-version", "20210307") - version("junit5-version", "5.9.0") - version("helidon-version", "3.0.2") - version("mockito-version", "4.6.1") - version("picocli-version", "4.6.3") - version("snakeyaml-version", "1.26") - version("testcontainers-version", "1.17.2") - version("classgraph-version", "4.8.65") - version("assertj-version", "3.23.1") - - bundle("junit5", listOf("junit-jupiter-api", "junit-jupiter-params", "junit-jupiter")) - bundle("mockito", listOf("mockito-inline", "mockito-jupiter")) - bundle("testcontainers", listOf("testcontainers-core", "testcontainers-junit")) - - bundle( - "testing", - listOf( - "junit-jupiter", - "junit-jupiter-api", - "junit-jupiter-params", - "mockito-inline", - "mockito-jupiter", - "hamcrest", - "awaitility", - "assertj-core")) - - library("awaitility", "org.awaitility", "awaitility").versionRef("awaitility-version") - library("besu-internal", "org.hyperledger.besu.internal", "crypto") - .versionRef("besu-internal-version") - library("commons-collections4", "org.apache.commons", "commons-collections4") - .versionRef("commons-collections4-version") - library("hamcrest", "org.hamcrest", "hamcrest").versionRef("hamcrest-version") - library("helidon-grpc-client", "io.helidon.grpc", "helidon-grpc-client") - .versionRef("helidon-version") - library("json", "org.json", "json").versionRef("json-version") - library("junit-jupiter", "org.junit.jupiter", "junit-jupiter").versionRef("junit5-version") - library("junit-jupiter-api", "org.junit.jupiter", "junit-jupiter-api") - .versionRef("junit5-version") - library("junit-jupiter-params", "org.junit.jupiter", "junit-jupiter-params") - .versionRef("junit5-version") - library("mockito-inline", "org.mockito", "mockito-inline").versionRef("mockito-version") - library("mockito-jupiter", "org.mockito", "mockito-junit-jupiter") - .versionRef("mockito-version") - library("picocli", "info.picocli", "picocli").versionRef("picocli-version") - library("snakeyaml", "org.yaml", "snakeyaml").versionRef("snakeyaml-version") - library("testcontainers-core", "org.testcontainers", "testcontainers") - .versionRef("testcontainers-version") - library("testcontainers-junit", "org.testcontainers", "junit-jupiter") - .versionRef("testcontainers-version") - library("classgraph", "io.github.classgraph", "classgraph").versionRef("classgraph-version") - library("assertj-core", "org.assertj", "assertj-core").versionRef("assertj-version") + @Suppress("UnstableApiUsage") + versionCatalogs { + // The libs of this catalog are the **ONLY** ones that are authorized to be part of the runtime + // distribution. These libs can be depended on during compilation, or bundled as part of + // runtime. + create("libs") { + // The HAPI API version to use, this need to match the tag set on gitRepositories above + version("hapi-version", "0.37.0-services-SNAPSHOT") + + // Definition of version numbers for all libraries + version("pbj-version", "0.5.1") + version("besu-version", "22.10.1") + version("besu-native-version", "0.6.1") + version("bouncycastle-version", "1.70") + version("caffeine-version", "3.0.6") + version("eclipse-collections-version", "10.4.0") + version("commons-codec-version", "1.15") + version("commons-io-version", "2.11.0") + version("commons-collections4-version", "4.4") + version("commons-lang3-version", "3.12.0") + version("dagger-version", "2.42") + version("eddsa-version", "0.3.0") + version("grpc-version", "1.50.2") + version("guava-version", "31.1-jre") + version("headlong-version", "6.1.1") + version("helidon-version", "3.0.2") + version("jackson-version", "2.13.3") + version("javax-annotation-version", "1.3.2") + version("javax-inject-version", "1") + version("jetbrains-annotation-version", "16.0.2") + version("log4j-version", "2.17.2") + version("netty-version", "4.1.66.Final") + version("protobuf-java-version", "3.19.4") + version("slf4j-version", "2.0.3") + version("swirlds-version", "0.36.1") + version("tuweni-version", "2.2.0") + version("jna-version", "5.12.1") + version("jsr305-version", "3.0.2") + version("spotbugs-version", "4.7.3") + version("helidon-grpc-version", "3.0.2") + + plugin("pbj", "com.hedera.pbj.pbj-compiler").versionRef("pbj-version") + + // List of bundles provided for us. When applicable, favor using these over individual + // libraries. + // Use when you need to use Besu + bundle( + "besu", + listOf("besu-bls12-381", "besu-evm", "besu-datatypes", "besu-secp256k1", "tuweni-units")) + // Use when you need to use bouncy castle + bundle("bouncycastle", listOf("bouncycastle-bcprov-jdk15on", "bouncycastle-bcpkix-jdk15on")) + // Use when you need to make use of dependency injection. + bundle("di", listOf("javax-inject", "dagger-api")) + // Use when you need a grpc server + bundle("helidon", listOf("helidon-server", "helidon-grpc-server", "helidon-io-grpc")) + // Use when you need logging + bundle("logging", listOf("log4j-api", "log4j-core", "log4j-slf4j", "slf4j-api")) + // Use when you need to depend upon netty + bundle("netty", listOf("netty-handler", "netty-transport-native-epoll")) + // Use when you depend upon all or swirlds + bundle( + "swirlds", + listOf( + "swirlds-common", + "swirlds-platform-core", + "swirlds-fchashmap", + "swirlds-merkle", + "swirlds-fcqueue", + "swirlds-jasperdb", + "swirlds-virtualmap")) + + // Define the individual libraries + library("pbj-runtime", "com.hedera.pbj", "pbj-runtime").versionRef("pbj-version") + library("besu-bls12-381", "org.hyperledger.besu", "bls12-381") + .versionRef("besu-native-version") + library("besu-secp256k1", "org.hyperledger.besu", "secp256k1") + .versionRef("besu-native-version") + library("besu-evm", "org.hyperledger.besu", "evm").versionRef("besu-version") + library("besu-datatypes", "org.hyperledger.besu", "besu-datatypes").versionRef("besu-version") + library("bouncycastle-bcprov-jdk15on", "org.bouncycastle", "bcprov-jdk15on") + .versionRef("bouncycastle-version") + library("bouncycastle-bcpkix-jdk15on", "org.bouncycastle", "bcpkix-jdk15on") + .versionRef("bouncycastle-version") + library("caffeine", "com.github.ben-manes.caffeine", "caffeine") + .versionRef("caffeine-version") + library("eclipse-collections", "org.eclipse.collections", "eclipse-collections") + .versionRef("eclipse-collections-version") + library("commons-collections4", "org.apache.commons", "commons-collections4") + .versionRef("commons-collections4-version") + library("commons-codec", "commons-codec", "commons-codec").versionRef("commons-codec-version") + library("commons-io", "commons-io", "commons-io").versionRef("commons-io-version") + library("commons-lang3", "org.apache.commons", "commons-lang3") + .versionRef("commons-lang3-version") + library("dagger-api", "com.google.dagger", "dagger").versionRef("dagger-version") + library("dagger-compiler", "com.google.dagger", "dagger-compiler") + .versionRef("dagger-version") + library("eddsa", "net.i2p.crypto", "eddsa").versionRef("eddsa-version") + library("grpc-stub", "io.grpc", "grpc-stub").versionRef("grpc-version") + library("grpc-protobuf", "io.grpc", "grpc-protobuf").versionRef("grpc-version") + library("grpc-netty", "io.grpc", "grpc-netty").versionRef("grpc-version") + library("guava", "com.google.guava", "guava").versionRef("guava-version") + library("hapi", "com.hedera.hashgraph", "hedera-protobuf-java-api").versionRef("hapi-version") + library("headlong", "com.esaulpaugh", "headlong").versionRef("headlong-version") + library("helidon-server", "io.helidon.webserver", "helidon-webserver-http2") + .versionRef("helidon-version") + library("helidon-grpc-server", "io.helidon.grpc", "helidon-grpc-server") + .versionRef("helidon-version") + library("helidon-io-grpc", "io.helidon.grpc", "io.grpc").versionRef("helidon-version") + library("jackson", "com.fasterxml.jackson.core", "jackson-databind") + .versionRef("jackson-version") + library("javax-annotation", "javax.annotation", "javax.annotation-api") + .versionRef("javax-annotation-version") + library("javax-inject", "javax.inject", "javax.inject").versionRef("javax-inject-version") + library("jetbrains-annotation", "org.jetbrains", "annotations") + .versionRef("jetbrains-annotation-version") + library("jsr305-annotation", "com.google.code.findbugs", "jsr305") + .versionRef("jsr305-version") + library("log4j-api", "org.apache.logging.log4j", "log4j-api").versionRef("log4j-version") + library("log4j-core", "org.apache.logging.log4j", "log4j-core").versionRef("log4j-version") + library("log4j-slf4j", "org.apache.logging.log4j", "log4j-slf4j-impl") + .versionRef("log4j-version") + library("netty-transport-native-epoll", "io.netty", "netty-transport-native-epoll") + .versionRef("netty-version") + library("netty-handler", "io.netty", "netty-handler").versionRef("netty-version") + library("protobuf-java", "com.google.protobuf", "protobuf-java") + .versionRef("protobuf-java-version") + library("swirlds-common", "com.swirlds", "swirlds-common").versionRef("swirlds-version") + library("swirlds-config", "com.swirlds", "swirlds-config").versionRef("swirlds-version") + library("swirlds-config-impl", "com.swirlds", "swirlds-config-impl").versionRef("swirlds-version") + library("slf4j-api", "org.slf4j", "slf4j-api").versionRef("slf4j-version") + library("slf4j-simple", "org.slf4j", "slf4j-api").versionRef("slf4j-version") + library("swirlds-platform-core", "com.swirlds", "swirlds-platform-core") + .versionRef("swirlds-version") + library("swirlds-fchashmap", "com.swirlds", "swirlds-fchashmap").versionRef("swirlds-version") + library("swirlds-merkle", "com.swirlds", "swirlds-merkle").versionRef("swirlds-version") + library("swirlds-fcqueue", "com.swirlds", "swirlds-fcqueue").versionRef("swirlds-version") + library("swirlds-jasperdb", "com.swirlds", "swirlds-jasperdb").versionRef("swirlds-version") + library("swirlds-virtualmap", "com.swirlds", "swirlds-virtualmap") + .versionRef("swirlds-version") + library("tuweni-units", "org.apache.tuweni", "tuweni-units").versionRef("tuweni-version") + library("jna", "net.java.dev.jna", "jna").versionRef("jna-version") + library("spotbugs-annotations", "com.github.spotbugs", "spotbugs-annotations") + .versionRef("spotbugs-version") + } + + // The libs of this catalog can be used for test or build uses. + create("testLibs") { + version("awaitility-version", "4.2.0") + version("besu-internal-version", "22.1.1") + version("commons-collections4-version", "4.4") + version("hamcrest-version", "2.2") + version("json-version", "20210307") + version("junit5-version", "5.9.0") + version("helidon-version", "3.0.2") + version("mockito-version", "4.6.1") + version("picocli-version", "4.6.3") + version("snakeyaml-version", "1.26") + version("testcontainers-version", "1.17.2") + version("classgraph-version", "4.8.65") + version("assertj-version", "3.23.1") + + bundle("junit5", listOf("junit-jupiter-api", "junit-jupiter-params", "junit-jupiter")) + bundle("mockito", listOf("mockito-inline", "mockito-jupiter")) + bundle("testcontainers", listOf("testcontainers-core", "testcontainers-junit")) + + bundle( + "testing", + listOf( + "junit-jupiter", + "junit-jupiter-api", + "junit-jupiter-params", + "mockito-inline", + "mockito-jupiter", + "hamcrest", + "awaitility", + "assertj-core")) + + library("awaitility", "org.awaitility", "awaitility").versionRef("awaitility-version") + library("besu-internal", "org.hyperledger.besu.internal", "crypto") + .versionRef("besu-internal-version") + library("commons-collections4", "org.apache.commons", "commons-collections4") + .versionRef("commons-collections4-version") + library("hamcrest", "org.hamcrest", "hamcrest").versionRef("hamcrest-version") + library("helidon-grpc-client", "io.helidon.grpc", "helidon-grpc-client") + .versionRef("helidon-version") + library("json", "org.json", "json").versionRef("json-version") + library("junit-jupiter", "org.junit.jupiter", "junit-jupiter").versionRef("junit5-version") + library("junit-jupiter-api", "org.junit.jupiter", "junit-jupiter-api") + .versionRef("junit5-version") + library("junit-jupiter-params", "org.junit.jupiter", "junit-jupiter-params") + .versionRef("junit5-version") + library("mockito-inline", "org.mockito", "mockito-inline").versionRef("mockito-version") + library("mockito-jupiter", "org.mockito", "mockito-junit-jupiter") + .versionRef("mockito-version") + library("picocli", "info.picocli", "picocli").versionRef("picocli-version") + library("snakeyaml", "org.yaml", "snakeyaml").versionRef("snakeyaml-version") + library("testcontainers-core", "org.testcontainers", "testcontainers") + .versionRef("testcontainers-version") + library("testcontainers-junit", "org.testcontainers", "junit-jupiter") + .versionRef("testcontainers-version") + library("classgraph", "io.github.classgraph", "classgraph").versionRef("classgraph-version") + library("assertj-core", "org.assertj", "assertj-core").versionRef("assertj-version") + } } - } } From aa4c2ce53940b2662ba50e13a97edb6f03a57961 Mon Sep 17 00:00:00 2001 From: Hendrik Ebbers Date: Mon, 17 Apr 2023 13:03:03 +0200 Subject: [PATCH 2/6] spotless Signed-off-by: Hendrik Ebbers --- hedera-node/hedera-app-spi/build.gradle.kts | 48 +- .../AbstractEnumConfigConverter.java | 3 +- .../config/converter/AccountIDConverter.java | 12 +- .../config/converter/ContractIDConverter.java | 12 +- .../spi/config/converter/FileIDConverter.java | 9 +- .../HederaFunctionalityConverter.java | 7 +- .../config/converter/ProfileConverter.java | 5 +- .../converter/SidecarTypeConverter.java | 7 +- .../AbstractEnumConfigConverterTest.java | 41 +- .../converter/AccountIDConverterTest.java | 46 +- .../converter/ContractIDConverterTest.java | 46 +- .../config/converter/FileIDConverterTest.java | 47 +- .../HederaFunctionalityConverterTest.java | 25 +- .../converter/ProfileConverterTest.java | 43 +- .../converter/SidecarTypeConverterTest.java | 26 +- .../node/app/config/converter/ClassCheck.java | 7 +- .../CongestionMultipliersConverter.java | 6 +- .../EntityScaleFactorsConverter.java | 6 +- .../config/converter/EntityTypeConverter.java | 9 +- .../converter/KnownBlockValuesConverter.java | 6 +- .../LegacyContractIdActivationsConverter.java | 3 +- .../converter/MapAccessTypeConverter.java | 7 +- .../converter/RecomputeTypeConverter.java | 7 +- .../converter/ScaleFactorConverter.java | 7 +- .../PropertySourceBasedConfigSource.java | 6 +- .../config/PropertySourceBasedConfigTest.java | 60 +-- .../CongestionMultipliersConverterTest.java | 25 +- .../EntityScaleFactorsConverterTest.java | 34 +- .../converter/EntityTypeConverterTest.java | 26 +- .../KnownBlockValuesConverterTest.java | 28 +- ...acyContractIdActivationsConverterTest.java | 28 +- .../converter/MapAccessTypeConverterTest.java | 25 +- .../converter/RecomputeTypeConverterTest.java | 25 +- .../converter/ScaleFactorConverterTest.java | 26 +- .../PropertySourceBasedConfigSourceTest.java | 9 +- settings.gradle.kts | 455 +++++++++--------- 36 files changed, 552 insertions(+), 630 deletions(-) diff --git a/hedera-node/hedera-app-spi/build.gradle.kts b/hedera-node/hedera-app-spi/build.gradle.kts index 64ff6f83887d..864d4036a90d 100644 --- a/hedera-node/hedera-app-spi/build.gradle.kts +++ b/hedera-node/hedera-app-spi/build.gradle.kts @@ -15,39 +15,39 @@ */ plugins { - id("com.hedera.hashgraph.conventions") - `java-test-fixtures` + id("com.hedera.hashgraph.conventions") + `java-test-fixtures` } description = "Hedera Application - SPI" configurations.all { - exclude("javax.annotation", "javax.annotation-api") - exclude("com.google.code.findbugs", "jsr305") - exclude("org.jetbrains", "annotations") - exclude("org.checkerframework", "checker-qual") + exclude("javax.annotation", "javax.annotation-api") + exclude("com.google.code.findbugs", "jsr305") + exclude("org.jetbrains", "annotations") + exclude("org.checkerframework", "checker-qual") - exclude("io.grpc", "grpc-core") - exclude("io.grpc", "grpc-context") - exclude("io.grpc", "grpc-api") - exclude("io.grpc", "grpc-testing") + exclude("io.grpc", "grpc-core") + exclude("io.grpc", "grpc-context") + exclude("io.grpc", "grpc-api") + exclude("io.grpc", "grpc-testing") } dependencies { - implementation(libs.swirlds.virtualmap) - implementation(libs.swirlds.jasperdb) - implementation(libs.swirlds.common) - api(libs.pbj.runtime) - api(libs.hapi) - api(libs.jsr305.annotation) - api(project(":hedera-node:hapi")) - compileOnlyApi(libs.spotbugs.annotations) + implementation(libs.swirlds.virtualmap) + implementation(libs.swirlds.jasperdb) + implementation(libs.swirlds.common) + api(libs.pbj.runtime) + api(libs.hapi) + api(libs.jsr305.annotation) + api(project(":hedera-node:hapi")) + compileOnlyApi(libs.spotbugs.annotations) - testRuntimeOnly(libs.swirlds.config.impl) - testImplementation(testLibs.bundles.testing) - testCompileOnly(libs.spotbugs.annotations) + testRuntimeOnly(libs.swirlds.config.impl) + testImplementation(testLibs.bundles.testing) + testCompileOnly(libs.spotbugs.annotations) - testFixturesCompileOnly(libs.spotbugs.annotations) - testFixturesCompileOnly(testLibs.assertj.core) - testFixturesApi(libs.swirlds.common) + testFixturesCompileOnly(libs.spotbugs.annotations) + testFixturesCompileOnly(testLibs.assertj.core) + testFixturesApi(libs.swirlds.common) } diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java index 749a63fe65aa..523c273ab548 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java index 8297ae6d9a14..e55237cbec79 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -24,13 +23,13 @@ public class AccountIDConverter implements ConfigConverter { @Override - public AccountID convert(final String value) - throws IllegalArgumentException, NullPointerException { + public AccountID convert(final String value) throws IllegalArgumentException, NullPointerException { if (value == null) { throw new NullPointerException("null can not be converted"); } try { - final long[] nums = Stream.of(value.split("[.]")).mapToLong(Long::parseLong).toArray(); + final long[] nums = + Stream.of(value.split("[.]")).mapToLong(Long::parseLong).toArray(); if (nums.length != 3) { throw new IllegalArgumentException("Does not match pattern 'A.B.C'"); } @@ -49,8 +48,7 @@ public AccountID convert(final String value) .accountNum(nums[2]) .build(); } catch (final Exception e) { - throw new IllegalArgumentException( - "'" + value + "' can not be parsed to " + AccountID.class.getName(), e); + throw new IllegalArgumentException("'" + value + "' can not be parsed to " + AccountID.class.getName(), e); } } } diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java index 98d6be0e5cfd..f3b777012198 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -24,13 +23,13 @@ public class ContractIDConverter implements ConfigConverter { @Override - public ContractID convert(final String value) - throws IllegalArgumentException, NullPointerException { + public ContractID convert(final String value) throws IllegalArgumentException, NullPointerException { if (value == null) { throw new NullPointerException("null can not be converted"); } try { - final long[] nums = Stream.of(value.split("[.]")).mapToLong(Long::valueOf).toArray(); + final long[] nums = + Stream.of(value.split("[.]")).mapToLong(Long::valueOf).toArray(); if (nums.length != 3) { throw new IllegalArgumentException("Does not match pattern 'A.B.C'"); } @@ -49,8 +48,7 @@ public ContractID convert(final String value) .contractNum(nums[2]) .build(); } catch (final Exception e) { - throw new IllegalArgumentException( - "'" + value + "' can not be parsed to " + ContractID.class.getName(), e); + throw new IllegalArgumentException("'" + value + "' can not be parsed to " + ContractID.class.getName(), e); } } } diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java index 9370e98c666c..50d136b42c38 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -29,7 +28,8 @@ public FileID convert(final String value) throws IllegalArgumentException, NullP throw new NullPointerException("null can not be converted"); } try { - final long[] nums = Stream.of(value.split("[.]")).mapToLong(Long::parseLong).toArray(); + final long[] nums = + Stream.of(value.split("[.]")).mapToLong(Long::parseLong).toArray(); if (nums.length != 3) { throw new IllegalArgumentException("Does not match pattern 'A.B.C'"); } @@ -48,8 +48,7 @@ public FileID convert(final String value) throws IllegalArgumentException, NullP .fileNum(nums[2]) .build(); } catch (final Exception e) { - throw new IllegalArgumentException( - "'" + value + "' can not be parsed to " + FileID.class.getName(), e); + throw new IllegalArgumentException("'" + value + "' can not be parsed to " + FileID.class.getName(), e); } } } diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java index 9ff353f4d8d8..703c02dca106 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -24,8 +23,8 @@ * Converter implementation for the config API to support {@link HederaFunctionality}. Based on * https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter explicitly */ -public class HederaFunctionalityConverter extends AbstractEnumConfigConverter implements - ConfigConverter { +public class HederaFunctionalityConverter extends AbstractEnumConfigConverter + implements ConfigConverter { @Override protected Class getEnumType() { diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java index 955b0921bde0..de1486cad1c3 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -38,7 +37,7 @@ public Profile convert(final String value) throws IllegalArgumentException, Null return Profile.TEST; } } catch (final Exception e) { - //ignore + // ignore } return Profile.valueOf(value.toUpperCase()); diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java index 4732f0a66cad..6d2f69cda83f 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -21,8 +20,8 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; -public class SidecarTypeConverter extends AbstractEnumConfigConverter implements - ConfigConverter { +public class SidecarTypeConverter extends AbstractEnumConfigConverter + implements ConfigConverter { @NonNull @Override diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java index b3fa9d332259..0a38ee59125e 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -34,8 +33,8 @@ class AbstractEnumConfigConverterTest { * Based on https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter * explicitly */ - private static class RetentionPolicyConverter extends AbstractEnumConfigConverter implements - ConfigConverter { + private static class RetentionPolicyConverter extends AbstractEnumConfigConverter + implements ConfigConverter { @Override protected Class getEnumType() { @@ -47,8 +46,8 @@ protected Class getEnumType() { * Based on https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter * explicitly */ - private static class ElementTypeConverter extends AbstractEnumConfigConverter implements - ConfigConverter { + private static class ElementTypeConverter extends AbstractEnumConfigConverter + implements ConfigConverter { @Override protected Class getEnumType() { @@ -58,39 +57,37 @@ protected Class getEnumType() { @Test void testNullValue() { - //given + // given final RetentionPolicyConverter converter = new RetentionPolicyConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidValue() { - //given + // given final RetentionPolicyConverter converter = new RetentionPolicyConverter(); - //then - assertThatThrownBy(() -> converter.convert("not-supported-value")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("not-supported-value")).isInstanceOf(IllegalArgumentException.class); } @Test void testValidValue() { - //given + // given final RetentionPolicyConverter converter = new RetentionPolicyConverter(); - //when + // when final RetentionPolicy source = converter.convert("SOURCE"); - //then + // then assertThat(source).isEqualTo(RetentionPolicy.SOURCE); } @Test void testIntegration() { - //given + // given final Configuration configuration = ConfigurationBuilder.create() .withSource(new SimpleConfigSource("retention-policy", "SOURCE")) .withSource(new SimpleConfigSource("element-type", "TYPE")) @@ -98,14 +95,12 @@ void testIntegration() { .withConverter(new ElementTypeConverter()) .build(); - //when + // when final RetentionPolicy source = configuration.getValue("retention-policy", RetentionPolicy.class); final ElementType type = configuration.getValue("element-type", ElementType.class); - //then + // then assertThat(source).isEqualTo(RetentionPolicy.SOURCE); assertThat(type).isEqualTo(ElementType.TYPE); } - - -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java index 1b400eb6d62f..a4e8d96b904b 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -29,27 +28,25 @@ class AccountIDConverterTest { @Test void testNullParam() { - //given + // given final AccountIDConverter converter = new AccountIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test @ParameterizedTest - @ValueSource(strings = {"", " ", " ", "a.b.b", - "1.b.c", "1.2.c", "a.2.3", - "1", "1.2", - ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4"}) + @ValueSource( + strings = { + "", " ", " ", "a.b.b", "1.b.c", "1.2.c", "a.2.3", "1", "1.2", ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4" + }) void testAllNotParseable(final String input) { - //given + // given final AccountIDConverter converter = new AccountIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(input)) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } @Test @@ -57,24 +54,23 @@ void testAllNotParseable(final String input) { @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) void testEdgeCasesForDiscussion(final String input) { - //given + // given final AccountIDConverter converter = new AccountIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(input)) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } @Test void testSimpleValue() { - //given + // given final AccountIDConverter converter = new AccountIDConverter(); final String value = "1.2.3"; - //when + // when final var result = converter.convert(value); - //then + // then assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(1L); assertThat(result.realmNum()).isEqualTo(2L); @@ -83,17 +79,17 @@ void testSimpleValue() { @Test void testLongValues() { - //given + // given final AccountIDConverter converter = new AccountIDConverter(); final String value = Long.MAX_VALUE + "." + Long.MAX_VALUE + ".0"; - //when + // when final var result = converter.convert(value); - //then + // then assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.accountNum()).isEqualTo(0); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java index 59de20fa7f82..16e9e835c3d8 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -29,27 +28,25 @@ class ContractIDConverterTest { @Test void testNullParam() { - //given + // given final ContractIDConverter converter = new ContractIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test @ParameterizedTest - @ValueSource(strings = {"", " ", " ", "a.b.b", - "1.b.c", "1.2.c", "a.2.3", - "1", "1.2", - ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4"}) + @ValueSource( + strings = { + "", " ", " ", "a.b.b", "1.b.c", "1.2.c", "a.2.3", "1", "1.2", ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4" + }) void testAllNotParseable(final String input) { - //given + // given final ContractIDConverter converter = new ContractIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(input)) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } @Test @@ -57,24 +54,23 @@ void testAllNotParseable(final String input) { @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) void testEdgeCasesForDiscussion(final String input) { - //given + // given final ContractIDConverter converter = new ContractIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(input)) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } @Test void testSimpleValue() { - //given + // given final ContractIDConverter converter = new ContractIDConverter(); final String value = "1.2.3"; - //when + // when final var result = converter.convert(value); - //then + // then assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(1L); assertThat(result.realmNum()).isEqualTo(2L); @@ -83,17 +79,17 @@ void testSimpleValue() { @Test void testLongValues() { - //given + // given final ContractIDConverter converter = new ContractIDConverter(); final String value = Long.MAX_VALUE + "." + Long.MAX_VALUE + ".0"; - //when + // when final var result = converter.convert(value); - //then + // then assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.contractNum()).isEqualTo(0); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java index 26f7f88308f1..8329626d53d0 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -29,27 +28,25 @@ class FileIDConverterTest { @Test void testNullParam() { - //given + // given final FileIDConverter converter = new FileIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test @ParameterizedTest - @ValueSource(strings = {"", " ", " ", "a.b.b", - "1.b.c", "1.2.c", "a.2.3", - "1", "1.2", - ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4"}) + @ValueSource( + strings = { + "", " ", " ", "a.b.b", "1.b.c", "1.2.c", "a.2.3", "1", "1.2", ".1.2.3", "..1.2.3", ".1.2.3.", "1.2.3.4" + }) void testAllNotParseable(final String input) { - //given + // given final FileIDConverter converter = new FileIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(input)) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } @Test @@ -57,24 +54,23 @@ void testAllNotParseable(final String input) { @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) void testEdgeCasesForDiscussion(final String input) { - //given + // given final FileIDConverter converter = new FileIDConverter(); - //then - assertThatThrownBy(() -> converter.convert(input)) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } @Test void testSimpleValue() { - //given + // given final FileIDConverter converter = new FileIDConverter(); final String value = "1.2.3"; - //when + // when final var result = converter.convert(value); - //then + // then assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(1L); assertThat(result.realmNum()).isEqualTo(2L); @@ -83,18 +79,17 @@ void testSimpleValue() { @Test void testLongValues() { - //given + // given final FileIDConverter converter = new FileIDConverter(); final String value = Long.MAX_VALUE + "." + Long.MAX_VALUE + ".0"; - //when + // when final var result = converter.convert(value); - //then + // then assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.fileNum()).isEqualTo(0); } - -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java index 92ce0c0276f5..43b481d44c84 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -27,33 +26,31 @@ class HederaFunctionalityConverterTest { @Test void testNullParam() { - //given + // given final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidParam() { - //given + // given final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } @Test void testValidParam() { - //given + // given final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); - //when + // when final HederaFunctionality cryptoTransfer = converter.convert("CRYPTO_TRANSFER"); - //then + // then assertThat(cryptoTransfer).isEqualTo(HederaFunctionality.CRYPTO_TRANSFER); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java index a56b89b32ded..2d1013344b4f 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -29,39 +28,47 @@ class ProfileConverterTest { @Test void testNullParam() { - //given + // given final ProfileConverter converter = new ProfileConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidParam() { - //given + // given final ProfileConverter converter = new ProfileConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } @Test @ParameterizedTest - @CsvSource({"DEV, DEV", "TEST, TEST", "PROD, PROD", - "dev, DEV", "test, TEST", "prod, PROD", - "dEv, DEV", "tEst, TEST", "pRod, PROD", - "0,DEV", "2,TEST", "1,PROD"}) + @CsvSource({ + "DEV, DEV", + "TEST, TEST", + "PROD, PROD", + "dev, DEV", + "test, TEST", + "prod, PROD", + "dEv, DEV", + "tEst, TEST", + "pRod, PROD", + "0,DEV", + "2,TEST", + "1,PROD" + }) void testValidParam(final String input, final String enumName) { - //given + // given final ProfileConverter converter = new ProfileConverter(); final Profile expected = Profile.valueOf(enumName); - //when + // when final Profile cryptoTransfer = converter.convert(input); - //then + // then assertThat(cryptoTransfer).isEqualTo(expected); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java index 7fe8327f088f..39fb264947e3 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.spi.config.converter; @@ -27,34 +26,31 @@ class SidecarTypeConverterTest { @Test void testNullParam() { - //given + // given final SidecarTypeConverter converter = new SidecarTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidParam() { - //given + // given final SidecarTypeConverter converter = new SidecarTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } @Test void testValidParam() { - //given + // given final SidecarTypeConverter converter = new SidecarTypeConverter(); - //when + // when final SidecarType sidecarType = converter.convert("SIDECAR_TYPE_UNKNOWN"); - //then + // then assertThat(sidecarType).isEqualTo(SidecarType.SIDECAR_TYPE_UNKNOWN); } - -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java index 50504f953848..d709a80d796b 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java @@ -5,21 +5,18 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; public class ClassCheck { - void foo() { - - } + void foo() {} } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java index dd9ed466cb7d..e31119b062fc 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -23,8 +22,7 @@ public class CongestionMultipliersConverter implements ConfigConverter { @Override - public CongestionMultipliers convert(final String value) - throws IllegalArgumentException, NullPointerException { + public CongestionMultipliers convert(final String value) throws IllegalArgumentException, NullPointerException { if (value == null) { throw new NullPointerException("null can not be converted"); } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java index 1c3168e0f4dc..56b184dbaae2 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -23,8 +22,7 @@ public class EntityScaleFactorsConverter implements ConfigConverter { @Override - public EntityScaleFactors convert(final String value) - throws IllegalArgumentException, NullPointerException { + public EntityScaleFactors convert(final String value) throws IllegalArgumentException, NullPointerException { if (value == null) { throw new NullPointerException("null can not be converted"); } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java index 86d7ccb6017c..c8c0271ee967 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -22,9 +21,9 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; -public class EntityTypeConverter extends AbstractEnumConfigConverter implements - ConfigConverter { - +public class EntityTypeConverter extends AbstractEnumConfigConverter + implements ConfigConverter { + @NonNull @Override protected Class getEnumType() { diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java index c8396670370d..de6e68e7b8e6 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -23,8 +22,7 @@ public class KnownBlockValuesConverter implements ConfigConverter { @Override - public KnownBlockValues convert(final String value) - throws IllegalArgumentException, NullPointerException { + public KnownBlockValues convert(final String value) throws IllegalArgumentException, NullPointerException { if (value == null) { throw new NullPointerException("null can not be converted"); } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java index 42a6d7010dd6..a8d008b6c4bc 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java index a57443524eb2..cdbf34e4989c 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -22,8 +21,8 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; -public class MapAccessTypeConverter extends AbstractEnumConfigConverter implements - ConfigConverter { +public class MapAccessTypeConverter extends AbstractEnumConfigConverter + implements ConfigConverter { @NonNull @Override protected Class getEnumType() { diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java index 627572f1031e..fead6b476e32 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -22,8 +21,8 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; -public class RecomputeTypeConverter extends AbstractEnumConfigConverter implements - ConfigConverter { +public class RecomputeTypeConverter extends AbstractEnumConfigConverter + implements ConfigConverter { @NonNull @Override diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java index 37811eac8895..a321c5b74df3 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -23,12 +22,10 @@ public class ScaleFactorConverter implements ConfigConverter { @Override - public ScaleFactor convert(final String value) - throws IllegalArgumentException, NullPointerException { + public ScaleFactor convert(final String value) throws IllegalArgumentException, NullPointerException { if (value == null) { throw new NullPointerException("null can not be converted"); } return ScaleFactor.from(value); } - } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java index 9154b7c97cbb..45ded0c0204d 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.source; @@ -29,8 +28,7 @@ public class PropertySourceBasedConfigSource implements ConfigSource { private final PropertySource propertySource; - public PropertySourceBasedConfigSource( - @NonNull final PropertySource propertySource) { + public PropertySourceBasedConfigSource(@NonNull final PropertySource propertySource) { this.propertySource = Objects.requireNonNull(propertySource, "propertySource"); } diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java index 417155fd0c7d..e711bc1c5e44 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config; @@ -87,12 +86,13 @@ void configureMockForConfigData() { rawData.put("test.sidecarType", "CONTRACT_ACTION"); BDDMockito.given(propertySource.allPropertyNames()).willReturn(rawData.keySet()); - rawData.forEach((key, value) -> BDDMockito.given(propertySource.getRawValue(key)).willReturn(value)); + rawData.forEach((key, value) -> + BDDMockito.given(propertySource.getRawValue(key)).willReturn(value)); } @Test public void testConfig() { - //given + // given final Configuration configuration = ConfigurationBuilder.create() .withConverter(new CongestionMultipliersConverter()) .withConverter(new EntityScaleFactorsConverter()) @@ -111,38 +111,28 @@ public void testConfig() { .withSource(new PropertySourceBasedConfigSource(propertySource)) .build(); - //when - final CongestionMultipliers congestionMultipliers = configuration.getValue("test.congestionMultipliers", - CongestionMultipliers.class); - final EntityScaleFactors entityScaleFactors = configuration.getValue("test.entityScaleFactors", - EntityScaleFactors.class); - final EntityType entityType = configuration.getValue("test.entityType", - EntityType.class); - final KnownBlockValues knownBlockValues = configuration.getValue("test.knownBlockValues", - KnownBlockValues.class); - final LegacyContractIdActivations legacyContractIdActivations = configuration.getValue( - "test.legacyContractIdActivations", - LegacyContractIdActivations.class); - final MapAccessType mapAccessType = configuration.getValue("test.mapAccessType", - MapAccessType.class); - final RecomputeType recomputeType = configuration.getValue("test.recomputeType", - RecomputeType.class); - final ScaleFactor scaleFactor = configuration.getValue("test.scaleFactor", - ScaleFactor.class); - final AccountID accountID = configuration.getValue("test.accountID", - AccountID.class); - final ContractID contractID = configuration.getValue("test.contractID", - ContractID.class); - final FileID fileID = configuration.getValue("test.fileID", - FileID.class); - final HederaFunctionality hederaFunctionality = configuration.getValue("test.hederaFunctionality", - HederaFunctionality.class); - final Profile profile = configuration.getValue("test.profile", - Profile.class); - final SidecarType sidecarType = configuration.getValue("test.sidecarType", - SidecarType.class); + // when + final CongestionMultipliers congestionMultipliers = + configuration.getValue("test.congestionMultipliers", CongestionMultipliers.class); + final EntityScaleFactors entityScaleFactors = + configuration.getValue("test.entityScaleFactors", EntityScaleFactors.class); + final EntityType entityType = configuration.getValue("test.entityType", EntityType.class); + final KnownBlockValues knownBlockValues = + configuration.getValue("test.knownBlockValues", KnownBlockValues.class); + final LegacyContractIdActivations legacyContractIdActivations = + configuration.getValue("test.legacyContractIdActivations", LegacyContractIdActivations.class); + final MapAccessType mapAccessType = configuration.getValue("test.mapAccessType", MapAccessType.class); + final RecomputeType recomputeType = configuration.getValue("test.recomputeType", RecomputeType.class); + final ScaleFactor scaleFactor = configuration.getValue("test.scaleFactor", ScaleFactor.class); + final AccountID accountID = configuration.getValue("test.accountID", AccountID.class); + final ContractID contractID = configuration.getValue("test.contractID", ContractID.class); + final FileID fileID = configuration.getValue("test.fileID", FileID.class); + final HederaFunctionality hederaFunctionality = + configuration.getValue("test.hederaFunctionality", HederaFunctionality.class); + final Profile profile = configuration.getValue("test.profile", Profile.class); + final SidecarType sidecarType = configuration.getValue("test.sidecarType", SidecarType.class); - //then + // then assertThat(congestionMultipliers).isNotNull(); assertThat(entityScaleFactors).isNotNull(); assertThat(entityType).isNotNull(); diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java index 01dd8afb51b6..45e0d508cb91 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/CongestionMultipliersConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -27,24 +26,23 @@ class CongestionMultipliersConverterTest { @Test void testNullValue() { - //given + // given final CongestionMultipliersConverter converter = new CongestionMultipliersConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testValidValue() { - //given + // given final CongestionMultipliersConverter converter = new CongestionMultipliersConverter(); final String input = "90,10x,95,25x,99,100x"; - //when + // when final CongestionMultipliers multipliers = converter.convert(input); - //then + // then assertThat(multipliers).isNotNull(); assertThat(multipliers.usagePercentTriggers()).containsExactly(90, 95, 99); assertThat(multipliers.multipliers()).containsExactly(10L, 25L, 100L); @@ -52,11 +50,10 @@ void testValidValue() { @Test void testInvalidValue() { - //given + // given final CongestionMultipliersConverter converter = new CongestionMultipliersConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java index a5add3e2cfe9..748b815318c6 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -28,46 +27,47 @@ class EntityScaleFactorsConverterTest { @Test void testNullValue() { - //given + // given final EntityScaleFactorsConverter converter = new EntityScaleFactorsConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testValidValue() { - //given + // given final EntityScaleFactorsConverter converter = new EntityScaleFactorsConverter(); final String input = "DEFAULT(90,10:1,95,25:1,99,100:1)"; - //when + // when final EntityScaleFactors entityScaleFactors = converter.convert(input); - //then + // then assertThat(entityScaleFactors).isNotNull(); assertThat(entityScaleFactors.typeScaleFactors()).isEmpty(); assertThat(entityScaleFactors.defaultScaleFactors()).isNotNull(); - assertThat(entityScaleFactors.defaultScaleFactors().usagePercentTriggers()).containsExactly(90, 95, 99); - assertThat(entityScaleFactors.defaultScaleFactors().scaleFactors()).containsExactly(ScaleFactor.from("10:1"), - ScaleFactor.from("25:1"), ScaleFactor.from("100:1")); + assertThat(entityScaleFactors.defaultScaleFactors().usagePercentTriggers()) + .containsExactly(90, 95, 99); + assertThat(entityScaleFactors.defaultScaleFactors().scaleFactors()) + .containsExactly(ScaleFactor.from("10:1"), ScaleFactor.from("25:1"), ScaleFactor.from("100:1")); } @Test void testEmptyValue() { - //given + // given final EntityScaleFactorsConverter converter = new EntityScaleFactorsConverter(); final String input = ""; - //when + // when final EntityScaleFactors entityScaleFactors = converter.convert(input); - //then + // then assertThat(entityScaleFactors).isNotNull(); assertThat(entityScaleFactors.typeScaleFactors()).isEmpty(); assertThat(entityScaleFactors.defaultScaleFactors()).isNotNull(); - assertThat(entityScaleFactors.defaultScaleFactors().usagePercentTriggers()).containsExactly(0); + assertThat(entityScaleFactors.defaultScaleFactors().usagePercentTriggers()) + .containsExactly(0); assertThat(entityScaleFactors.defaultScaleFactors().scaleFactors()).containsExactly(ScaleFactor.from("1:1")); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java index 426fb26e3e6d..e6bf1315636e 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/EntityTypeConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -27,34 +26,31 @@ class EntityTypeConverterTest { @Test void testNullParam() { - //given + // given final EntityTypeConverter converter = new EntityTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidParam() { - //given + // given final EntityTypeConverter converter = new EntityTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } @Test void testValidParam() { - //given + // given final EntityTypeConverter converter = new EntityTypeConverter(); - //when + // when final EntityType entityType = converter.convert("ACCOUNT"); - //then + // then assertThat(entityType).isEqualTo(EntityType.ACCOUNT); } - -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java index c9086f4a63a7..03e0a094b947 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/KnownBlockValuesConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -27,37 +26,36 @@ class KnownBlockValuesConverterTest { @Test void testNullValue() { - //given + // given final KnownBlockValuesConverter converter = new KnownBlockValuesConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testValidValue() { - //given + // given final KnownBlockValuesConverter converter = new KnownBlockValuesConverter(); final String input = "c9e37a7a454638ca62662bd1a06de49ef40b3444203fe329bbc81363604ea7f8@666"; - //when + // when final KnownBlockValues knownBlockValues = converter.convert(input); - //then + // then assertThat(knownBlockValues).isNotNull(); assertThat(knownBlockValues.number()).isEqualTo(666L); - assertThat(knownBlockValues.hash()).asHexString() + assertThat(knownBlockValues.hash()) + .asHexString() .isEqualTo("C9E37A7A454638CA62662BD1A06DE49EF40B3444203FE329BBC81363604EA7F8"); } @Test void testInvalidValue() { - //given + // given final KnownBlockValuesConverter converter = new KnownBlockValuesConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java index f86286d08f15..13ce589f6f19 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -29,26 +28,26 @@ class LegacyContractIdActivationsConverterTest { @Test void testNullValue() { - //given + // given final LegacyContractIdActivationsConverter converter = new LegacyContractIdActivationsConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testValidValue() { - //given + // given final LegacyContractIdActivationsConverter converter = new LegacyContractIdActivationsConverter(); final String input = "1058134by[1062784]"; - //when + // when final LegacyContractIdActivations contractIdActivations = converter.convert(input); - //then + // then assertThat(contractIdActivations).isNotNull(); - assertThat(contractIdActivations.privilegedContracts()).hasSize(1) + assertThat(contractIdActivations.privilegedContracts()) + .hasSize(1) .containsEntry( Address.fromHexString("0x0000000000000000000000000000000000102556"), Set.of(Address.fromHexString("0x0000000000000000000000000000000000103780"))); @@ -56,11 +55,10 @@ void testValidValue() { @Test void testInvalidValue() { - //given + // given final LegacyContractIdActivationsConverter converter = new LegacyContractIdActivationsConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java index 4febed89c416..2a9b59504ece 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/MapAccessTypeConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -27,33 +26,31 @@ class MapAccessTypeConverterTest { @Test void testNullParam() { - //given + // given final MapAccessTypeConverter converter = new MapAccessTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidParam() { - //given + // given final MapAccessTypeConverter converter = new MapAccessTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } @Test void testValidParam() { - //given + // given final MapAccessTypeConverter converter = new MapAccessTypeConverter(); - //when + // when final MapAccessType entityType = converter.convert("ACCOUNTS_GET"); - //then + // then assertThat(entityType).isEqualTo(MapAccessType.ACCOUNTS_GET); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java index 4f6cdfb9f22e..3db782523f62 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/RecomputeTypeConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -27,33 +26,31 @@ class RecomputeTypeConverterTest { @Test void testNullParam() { - //given + // given final RecomputeTypeConverter converter = new RecomputeTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testInvalidParam() { - //given + // given final RecomputeTypeConverter converter = new RecomputeTypeConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } @Test void testValidParam() { - //given + // given final RecomputeTypeConverter converter = new RecomputeTypeConverter(); - //when + // when final RecomputeType entityType = converter.convert("NODE_STAKES"); - //then + // then assertThat(entityType).isEqualTo(RecomputeType.NODE_STAKES); } -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java index 8b7665ac45b7..4a22f1f22e53 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/converter/ScaleFactorConverterTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.converter; @@ -27,24 +26,23 @@ class ScaleFactorConverterTest { @Test void testNullValue() { - //given + // given final ScaleFactorConverter converter = new ScaleFactorConverter(); - //then - assertThatThrownBy(() -> converter.convert(null)) - .isInstanceOf(NullPointerException.class); + // then + assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } @Test void testValidValue() { - //given + // given final ScaleFactorConverter converter = new ScaleFactorConverter(); final String input = "1:3"; - //when + // when final ScaleFactor scaleFactor = converter.convert(input); - //then + // then assertThat(scaleFactor).isNotNull(); assertThat(scaleFactor.numerator()).isEqualTo(1); assertThat(scaleFactor.denominator()).isEqualTo(3); @@ -52,12 +50,10 @@ void testValidValue() { @Test void testInvalidValue() { - //given + // given final ScaleFactorConverter converter = new ScaleFactorConverter(); - //then - assertThatThrownBy(() -> converter.convert("null")) - .isInstanceOf(IllegalArgumentException.class); + // then + assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } - -} \ No newline at end of file +} diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java index 3b4d02592ad2..01a9adb0057d 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSourceTest.java @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package com.hedera.node.app.config.source; @@ -44,11 +43,9 @@ void configureMockForConfigData() { BDDMockito.given(propertySource.getRawValue("c")).willReturn("result-c"); } - @Test void testNullParam() { - assertThatThrownBy(() -> new PropertySourceBasedConfigSource(null)) - .isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new PropertySourceBasedConfigSource(null)).isInstanceOf(NullPointerException.class); } @Test @@ -60,4 +57,4 @@ void testUsageParam() { assertThat(configSource.getValue("b")).isEqualTo("result-b"); assertThat(configSource.getValue("c")).isEqualTo("result-c"); } -} \ No newline at end of file +} diff --git a/settings.gradle.kts b/settings.gradle.kts index c54dacfbe33f..7b22b5b490c3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,19 +18,19 @@ import me.champeau.gradle.igp.gitRepositories // Add local maven build directory to plugin repos pluginManagement { - repositories { - gradlePluginPortal() - mavenCentral() - mavenLocal() - maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } - } + repositories { + gradlePluginPortal() + mavenCentral() + mavenLocal() + maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } + } } plugins { - id("com.gradle.enterprise").version("3.11.4") - // Use GIT plugin to clone HAPI protobuf files - // See documentation https://melix.github.io/includegit-gradle-plugin/latest/index.html - id("me.champeau.includegit").version("0.1.6") + id("com.gradle.enterprise").version("3.11.4") + // Use GIT plugin to clone HAPI protobuf files + // See documentation https://melix.github.io/includegit-gradle-plugin/latest/index.html + id("me.champeau.includegit").version("0.1.6") } include(":hedera-node") @@ -87,229 +87,230 @@ include(":hedera-node:test-clients") // Enable Gradle Build Scan gradleEnterprise { - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" - } + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } } gitRepositories { - checkoutsDirectory.set(file(rootProject.projectDir.absolutePath + "/hedera-node/hapi/")) - include("hedera-protobufs") { - uri.set("https://github.com/hashgraph/hedera-protobufs.git") - // choose tag or branch of HAPI you would like to test with - // this looks for a tag in hedera-protobufs repo - // This version needs to match tha HAPI version below in versionCatalogs - tag.set("add-pbj-types-for-state") - // do not load project from repo - autoInclude.set(false) - } + checkoutsDirectory.set(file(rootProject.projectDir.absolutePath + "/hedera-node/hapi/")) + include("hedera-protobufs") { + uri.set("https://github.com/hashgraph/hedera-protobufs.git") + // choose tag or branch of HAPI you would like to test with + // this looks for a tag in hedera-protobufs repo + // This version needs to match tha HAPI version below in versionCatalogs + tag.set("add-pbj-types-for-state") + // do not load project from repo + autoInclude.set(false) + } } // Define the library catalogs available for projects to make use of dependencyResolutionManagement { - @Suppress("UnstableApiUsage") - versionCatalogs { - // The libs of this catalog are the **ONLY** ones that are authorized to be part of the runtime - // distribution. These libs can be depended on during compilation, or bundled as part of - // runtime. - create("libs") { - // The HAPI API version to use, this need to match the tag set on gitRepositories above - version("hapi-version", "0.37.0-services-SNAPSHOT") - - // Definition of version numbers for all libraries - version("pbj-version", "0.5.1") - version("besu-version", "22.10.1") - version("besu-native-version", "0.6.1") - version("bouncycastle-version", "1.70") - version("caffeine-version", "3.0.6") - version("eclipse-collections-version", "10.4.0") - version("commons-codec-version", "1.15") - version("commons-io-version", "2.11.0") - version("commons-collections4-version", "4.4") - version("commons-lang3-version", "3.12.0") - version("dagger-version", "2.42") - version("eddsa-version", "0.3.0") - version("grpc-version", "1.50.2") - version("guava-version", "31.1-jre") - version("headlong-version", "6.1.1") - version("helidon-version", "3.0.2") - version("jackson-version", "2.13.3") - version("javax-annotation-version", "1.3.2") - version("javax-inject-version", "1") - version("jetbrains-annotation-version", "16.0.2") - version("log4j-version", "2.17.2") - version("netty-version", "4.1.66.Final") - version("protobuf-java-version", "3.19.4") - version("slf4j-version", "2.0.3") - version("swirlds-version", "0.36.1") - version("tuweni-version", "2.2.0") - version("jna-version", "5.12.1") - version("jsr305-version", "3.0.2") - version("spotbugs-version", "4.7.3") - version("helidon-grpc-version", "3.0.2") - - plugin("pbj", "com.hedera.pbj.pbj-compiler").versionRef("pbj-version") - - // List of bundles provided for us. When applicable, favor using these over individual - // libraries. - // Use when you need to use Besu - bundle( - "besu", - listOf("besu-bls12-381", "besu-evm", "besu-datatypes", "besu-secp256k1", "tuweni-units")) - // Use when you need to use bouncy castle - bundle("bouncycastle", listOf("bouncycastle-bcprov-jdk15on", "bouncycastle-bcpkix-jdk15on")) - // Use when you need to make use of dependency injection. - bundle("di", listOf("javax-inject", "dagger-api")) - // Use when you need a grpc server - bundle("helidon", listOf("helidon-server", "helidon-grpc-server", "helidon-io-grpc")) - // Use when you need logging - bundle("logging", listOf("log4j-api", "log4j-core", "log4j-slf4j", "slf4j-api")) - // Use when you need to depend upon netty - bundle("netty", listOf("netty-handler", "netty-transport-native-epoll")) - // Use when you depend upon all or swirlds - bundle( - "swirlds", - listOf( - "swirlds-common", - "swirlds-platform-core", - "swirlds-fchashmap", - "swirlds-merkle", - "swirlds-fcqueue", - "swirlds-jasperdb", - "swirlds-virtualmap")) - - // Define the individual libraries - library("pbj-runtime", "com.hedera.pbj", "pbj-runtime").versionRef("pbj-version") - library("besu-bls12-381", "org.hyperledger.besu", "bls12-381") - .versionRef("besu-native-version") - library("besu-secp256k1", "org.hyperledger.besu", "secp256k1") - .versionRef("besu-native-version") - library("besu-evm", "org.hyperledger.besu", "evm").versionRef("besu-version") - library("besu-datatypes", "org.hyperledger.besu", "besu-datatypes").versionRef("besu-version") - library("bouncycastle-bcprov-jdk15on", "org.bouncycastle", "bcprov-jdk15on") - .versionRef("bouncycastle-version") - library("bouncycastle-bcpkix-jdk15on", "org.bouncycastle", "bcpkix-jdk15on") - .versionRef("bouncycastle-version") - library("caffeine", "com.github.ben-manes.caffeine", "caffeine") - .versionRef("caffeine-version") - library("eclipse-collections", "org.eclipse.collections", "eclipse-collections") - .versionRef("eclipse-collections-version") - library("commons-collections4", "org.apache.commons", "commons-collections4") - .versionRef("commons-collections4-version") - library("commons-codec", "commons-codec", "commons-codec").versionRef("commons-codec-version") - library("commons-io", "commons-io", "commons-io").versionRef("commons-io-version") - library("commons-lang3", "org.apache.commons", "commons-lang3") - .versionRef("commons-lang3-version") - library("dagger-api", "com.google.dagger", "dagger").versionRef("dagger-version") - library("dagger-compiler", "com.google.dagger", "dagger-compiler") - .versionRef("dagger-version") - library("eddsa", "net.i2p.crypto", "eddsa").versionRef("eddsa-version") - library("grpc-stub", "io.grpc", "grpc-stub").versionRef("grpc-version") - library("grpc-protobuf", "io.grpc", "grpc-protobuf").versionRef("grpc-version") - library("grpc-netty", "io.grpc", "grpc-netty").versionRef("grpc-version") - library("guava", "com.google.guava", "guava").versionRef("guava-version") - library("hapi", "com.hedera.hashgraph", "hedera-protobuf-java-api").versionRef("hapi-version") - library("headlong", "com.esaulpaugh", "headlong").versionRef("headlong-version") - library("helidon-server", "io.helidon.webserver", "helidon-webserver-http2") - .versionRef("helidon-version") - library("helidon-grpc-server", "io.helidon.grpc", "helidon-grpc-server") - .versionRef("helidon-version") - library("helidon-io-grpc", "io.helidon.grpc", "io.grpc").versionRef("helidon-version") - library("jackson", "com.fasterxml.jackson.core", "jackson-databind") - .versionRef("jackson-version") - library("javax-annotation", "javax.annotation", "javax.annotation-api") - .versionRef("javax-annotation-version") - library("javax-inject", "javax.inject", "javax.inject").versionRef("javax-inject-version") - library("jetbrains-annotation", "org.jetbrains", "annotations") - .versionRef("jetbrains-annotation-version") - library("jsr305-annotation", "com.google.code.findbugs", "jsr305") - .versionRef("jsr305-version") - library("log4j-api", "org.apache.logging.log4j", "log4j-api").versionRef("log4j-version") - library("log4j-core", "org.apache.logging.log4j", "log4j-core").versionRef("log4j-version") - library("log4j-slf4j", "org.apache.logging.log4j", "log4j-slf4j-impl") - .versionRef("log4j-version") - library("netty-transport-native-epoll", "io.netty", "netty-transport-native-epoll") - .versionRef("netty-version") - library("netty-handler", "io.netty", "netty-handler").versionRef("netty-version") - library("protobuf-java", "com.google.protobuf", "protobuf-java") - .versionRef("protobuf-java-version") - library("swirlds-common", "com.swirlds", "swirlds-common").versionRef("swirlds-version") - library("swirlds-config", "com.swirlds", "swirlds-config").versionRef("swirlds-version") - library("swirlds-config-impl", "com.swirlds", "swirlds-config-impl").versionRef("swirlds-version") - library("slf4j-api", "org.slf4j", "slf4j-api").versionRef("slf4j-version") - library("slf4j-simple", "org.slf4j", "slf4j-api").versionRef("slf4j-version") - library("swirlds-platform-core", "com.swirlds", "swirlds-platform-core") - .versionRef("swirlds-version") - library("swirlds-fchashmap", "com.swirlds", "swirlds-fchashmap").versionRef("swirlds-version") - library("swirlds-merkle", "com.swirlds", "swirlds-merkle").versionRef("swirlds-version") - library("swirlds-fcqueue", "com.swirlds", "swirlds-fcqueue").versionRef("swirlds-version") - library("swirlds-jasperdb", "com.swirlds", "swirlds-jasperdb").versionRef("swirlds-version") - library("swirlds-virtualmap", "com.swirlds", "swirlds-virtualmap") - .versionRef("swirlds-version") - library("tuweni-units", "org.apache.tuweni", "tuweni-units").versionRef("tuweni-version") - library("jna", "net.java.dev.jna", "jna").versionRef("jna-version") - library("spotbugs-annotations", "com.github.spotbugs", "spotbugs-annotations") - .versionRef("spotbugs-version") - } - - // The libs of this catalog can be used for test or build uses. - create("testLibs") { - version("awaitility-version", "4.2.0") - version("besu-internal-version", "22.1.1") - version("commons-collections4-version", "4.4") - version("hamcrest-version", "2.2") - version("json-version", "20210307") - version("junit5-version", "5.9.0") - version("helidon-version", "3.0.2") - version("mockito-version", "4.6.1") - version("picocli-version", "4.6.3") - version("snakeyaml-version", "1.26") - version("testcontainers-version", "1.17.2") - version("classgraph-version", "4.8.65") - version("assertj-version", "3.23.1") - - bundle("junit5", listOf("junit-jupiter-api", "junit-jupiter-params", "junit-jupiter")) - bundle("mockito", listOf("mockito-inline", "mockito-jupiter")) - bundle("testcontainers", listOf("testcontainers-core", "testcontainers-junit")) - - bundle( - "testing", - listOf( - "junit-jupiter", - "junit-jupiter-api", - "junit-jupiter-params", - "mockito-inline", - "mockito-jupiter", - "hamcrest", - "awaitility", - "assertj-core")) - - library("awaitility", "org.awaitility", "awaitility").versionRef("awaitility-version") - library("besu-internal", "org.hyperledger.besu.internal", "crypto") - .versionRef("besu-internal-version") - library("commons-collections4", "org.apache.commons", "commons-collections4") - .versionRef("commons-collections4-version") - library("hamcrest", "org.hamcrest", "hamcrest").versionRef("hamcrest-version") - library("helidon-grpc-client", "io.helidon.grpc", "helidon-grpc-client") - .versionRef("helidon-version") - library("json", "org.json", "json").versionRef("json-version") - library("junit-jupiter", "org.junit.jupiter", "junit-jupiter").versionRef("junit5-version") - library("junit-jupiter-api", "org.junit.jupiter", "junit-jupiter-api") - .versionRef("junit5-version") - library("junit-jupiter-params", "org.junit.jupiter", "junit-jupiter-params") - .versionRef("junit5-version") - library("mockito-inline", "org.mockito", "mockito-inline").versionRef("mockito-version") - library("mockito-jupiter", "org.mockito", "mockito-junit-jupiter") - .versionRef("mockito-version") - library("picocli", "info.picocli", "picocli").versionRef("picocli-version") - library("snakeyaml", "org.yaml", "snakeyaml").versionRef("snakeyaml-version") - library("testcontainers-core", "org.testcontainers", "testcontainers") - .versionRef("testcontainers-version") - library("testcontainers-junit", "org.testcontainers", "junit-jupiter") - .versionRef("testcontainers-version") - library("classgraph", "io.github.classgraph", "classgraph").versionRef("classgraph-version") - library("assertj-core", "org.assertj", "assertj-core").versionRef("assertj-version") - } + @Suppress("UnstableApiUsage") + versionCatalogs { + // The libs of this catalog are the **ONLY** ones that are authorized to be part of the runtime + // distribution. These libs can be depended on during compilation, or bundled as part of + // runtime. + create("libs") { + // The HAPI API version to use, this need to match the tag set on gitRepositories above + version("hapi-version", "0.37.0-services-SNAPSHOT") + + // Definition of version numbers for all libraries + version("pbj-version", "0.5.1") + version("besu-version", "22.10.1") + version("besu-native-version", "0.6.1") + version("bouncycastle-version", "1.70") + version("caffeine-version", "3.0.6") + version("eclipse-collections-version", "10.4.0") + version("commons-codec-version", "1.15") + version("commons-io-version", "2.11.0") + version("commons-collections4-version", "4.4") + version("commons-lang3-version", "3.12.0") + version("dagger-version", "2.42") + version("eddsa-version", "0.3.0") + version("grpc-version", "1.50.2") + version("guava-version", "31.1-jre") + version("headlong-version", "6.1.1") + version("helidon-version", "3.0.2") + version("jackson-version", "2.13.3") + version("javax-annotation-version", "1.3.2") + version("javax-inject-version", "1") + version("jetbrains-annotation-version", "16.0.2") + version("log4j-version", "2.17.2") + version("netty-version", "4.1.66.Final") + version("protobuf-java-version", "3.19.4") + version("slf4j-version", "2.0.3") + version("swirlds-version", "0.36.1") + version("tuweni-version", "2.2.0") + version("jna-version", "5.12.1") + version("jsr305-version", "3.0.2") + version("spotbugs-version", "4.7.3") + version("helidon-grpc-version", "3.0.2") + + plugin("pbj", "com.hedera.pbj.pbj-compiler").versionRef("pbj-version") + + // List of bundles provided for us. When applicable, favor using these over individual + // libraries. + // Use when you need to use Besu + bundle( + "besu", + listOf("besu-bls12-381", "besu-evm", "besu-datatypes", "besu-secp256k1", "tuweni-units")) + // Use when you need to use bouncy castle + bundle("bouncycastle", listOf("bouncycastle-bcprov-jdk15on", "bouncycastle-bcpkix-jdk15on")) + // Use when you need to make use of dependency injection. + bundle("di", listOf("javax-inject", "dagger-api")) + // Use when you need a grpc server + bundle("helidon", listOf("helidon-server", "helidon-grpc-server", "helidon-io-grpc")) + // Use when you need logging + bundle("logging", listOf("log4j-api", "log4j-core", "log4j-slf4j", "slf4j-api")) + // Use when you need to depend upon netty + bundle("netty", listOf("netty-handler", "netty-transport-native-epoll")) + // Use when you depend upon all or swirlds + bundle( + "swirlds", + listOf( + "swirlds-common", + "swirlds-platform-core", + "swirlds-fchashmap", + "swirlds-merkle", + "swirlds-fcqueue", + "swirlds-jasperdb", + "swirlds-virtualmap")) + + // Define the individual libraries + library("pbj-runtime", "com.hedera.pbj", "pbj-runtime").versionRef("pbj-version") + library("besu-bls12-381", "org.hyperledger.besu", "bls12-381") + .versionRef("besu-native-version") + library("besu-secp256k1", "org.hyperledger.besu", "secp256k1") + .versionRef("besu-native-version") + library("besu-evm", "org.hyperledger.besu", "evm").versionRef("besu-version") + library("besu-datatypes", "org.hyperledger.besu", "besu-datatypes").versionRef("besu-version") + library("bouncycastle-bcprov-jdk15on", "org.bouncycastle", "bcprov-jdk15on") + .versionRef("bouncycastle-version") + library("bouncycastle-bcpkix-jdk15on", "org.bouncycastle", "bcpkix-jdk15on") + .versionRef("bouncycastle-version") + library("caffeine", "com.github.ben-manes.caffeine", "caffeine") + .versionRef("caffeine-version") + library("eclipse-collections", "org.eclipse.collections", "eclipse-collections") + .versionRef("eclipse-collections-version") + library("commons-collections4", "org.apache.commons", "commons-collections4") + .versionRef("commons-collections4-version") + library("commons-codec", "commons-codec", "commons-codec").versionRef("commons-codec-version") + library("commons-io", "commons-io", "commons-io").versionRef("commons-io-version") + library("commons-lang3", "org.apache.commons", "commons-lang3") + .versionRef("commons-lang3-version") + library("dagger-api", "com.google.dagger", "dagger").versionRef("dagger-version") + library("dagger-compiler", "com.google.dagger", "dagger-compiler") + .versionRef("dagger-version") + library("eddsa", "net.i2p.crypto", "eddsa").versionRef("eddsa-version") + library("grpc-stub", "io.grpc", "grpc-stub").versionRef("grpc-version") + library("grpc-protobuf", "io.grpc", "grpc-protobuf").versionRef("grpc-version") + library("grpc-netty", "io.grpc", "grpc-netty").versionRef("grpc-version") + library("guava", "com.google.guava", "guava").versionRef("guava-version") + library("hapi", "com.hedera.hashgraph", "hedera-protobuf-java-api").versionRef("hapi-version") + library("headlong", "com.esaulpaugh", "headlong").versionRef("headlong-version") + library("helidon-server", "io.helidon.webserver", "helidon-webserver-http2") + .versionRef("helidon-version") + library("helidon-grpc-server", "io.helidon.grpc", "helidon-grpc-server") + .versionRef("helidon-version") + library("helidon-io-grpc", "io.helidon.grpc", "io.grpc").versionRef("helidon-version") + library("jackson", "com.fasterxml.jackson.core", "jackson-databind") + .versionRef("jackson-version") + library("javax-annotation", "javax.annotation", "javax.annotation-api") + .versionRef("javax-annotation-version") + library("javax-inject", "javax.inject", "javax.inject").versionRef("javax-inject-version") + library("jetbrains-annotation", "org.jetbrains", "annotations") + .versionRef("jetbrains-annotation-version") + library("jsr305-annotation", "com.google.code.findbugs", "jsr305") + .versionRef("jsr305-version") + library("log4j-api", "org.apache.logging.log4j", "log4j-api").versionRef("log4j-version") + library("log4j-core", "org.apache.logging.log4j", "log4j-core").versionRef("log4j-version") + library("log4j-slf4j", "org.apache.logging.log4j", "log4j-slf4j-impl") + .versionRef("log4j-version") + library("netty-transport-native-epoll", "io.netty", "netty-transport-native-epoll") + .versionRef("netty-version") + library("netty-handler", "io.netty", "netty-handler").versionRef("netty-version") + library("protobuf-java", "com.google.protobuf", "protobuf-java") + .versionRef("protobuf-java-version") + library("swirlds-common", "com.swirlds", "swirlds-common").versionRef("swirlds-version") + library("swirlds-config", "com.swirlds", "swirlds-config").versionRef("swirlds-version") + library("swirlds-config-impl", "com.swirlds", "swirlds-config-impl") + .versionRef("swirlds-version") + library("slf4j-api", "org.slf4j", "slf4j-api").versionRef("slf4j-version") + library("slf4j-simple", "org.slf4j", "slf4j-api").versionRef("slf4j-version") + library("swirlds-platform-core", "com.swirlds", "swirlds-platform-core") + .versionRef("swirlds-version") + library("swirlds-fchashmap", "com.swirlds", "swirlds-fchashmap").versionRef("swirlds-version") + library("swirlds-merkle", "com.swirlds", "swirlds-merkle").versionRef("swirlds-version") + library("swirlds-fcqueue", "com.swirlds", "swirlds-fcqueue").versionRef("swirlds-version") + library("swirlds-jasperdb", "com.swirlds", "swirlds-jasperdb").versionRef("swirlds-version") + library("swirlds-virtualmap", "com.swirlds", "swirlds-virtualmap") + .versionRef("swirlds-version") + library("tuweni-units", "org.apache.tuweni", "tuweni-units").versionRef("tuweni-version") + library("jna", "net.java.dev.jna", "jna").versionRef("jna-version") + library("spotbugs-annotations", "com.github.spotbugs", "spotbugs-annotations") + .versionRef("spotbugs-version") + } + + // The libs of this catalog can be used for test or build uses. + create("testLibs") { + version("awaitility-version", "4.2.0") + version("besu-internal-version", "22.1.1") + version("commons-collections4-version", "4.4") + version("hamcrest-version", "2.2") + version("json-version", "20210307") + version("junit5-version", "5.9.0") + version("helidon-version", "3.0.2") + version("mockito-version", "4.6.1") + version("picocli-version", "4.6.3") + version("snakeyaml-version", "1.26") + version("testcontainers-version", "1.17.2") + version("classgraph-version", "4.8.65") + version("assertj-version", "3.23.1") + + bundle("junit5", listOf("junit-jupiter-api", "junit-jupiter-params", "junit-jupiter")) + bundle("mockito", listOf("mockito-inline", "mockito-jupiter")) + bundle("testcontainers", listOf("testcontainers-core", "testcontainers-junit")) + + bundle( + "testing", + listOf( + "junit-jupiter", + "junit-jupiter-api", + "junit-jupiter-params", + "mockito-inline", + "mockito-jupiter", + "hamcrest", + "awaitility", + "assertj-core")) + + library("awaitility", "org.awaitility", "awaitility").versionRef("awaitility-version") + library("besu-internal", "org.hyperledger.besu.internal", "crypto") + .versionRef("besu-internal-version") + library("commons-collections4", "org.apache.commons", "commons-collections4") + .versionRef("commons-collections4-version") + library("hamcrest", "org.hamcrest", "hamcrest").versionRef("hamcrest-version") + library("helidon-grpc-client", "io.helidon.grpc", "helidon-grpc-client") + .versionRef("helidon-version") + library("json", "org.json", "json").versionRef("json-version") + library("junit-jupiter", "org.junit.jupiter", "junit-jupiter").versionRef("junit5-version") + library("junit-jupiter-api", "org.junit.jupiter", "junit-jupiter-api") + .versionRef("junit5-version") + library("junit-jupiter-params", "org.junit.jupiter", "junit-jupiter-params") + .versionRef("junit5-version") + library("mockito-inline", "org.mockito", "mockito-inline").versionRef("mockito-version") + library("mockito-jupiter", "org.mockito", "mockito-junit-jupiter") + .versionRef("mockito-version") + library("picocli", "info.picocli", "picocli").versionRef("picocli-version") + library("snakeyaml", "org.yaml", "snakeyaml").versionRef("snakeyaml-version") + library("testcontainers-core", "org.testcontainers", "testcontainers") + .versionRef("testcontainers-version") + library("testcontainers-junit", "org.testcontainers", "junit-jupiter") + .versionRef("testcontainers-version") + library("classgraph", "io.github.classgraph", "classgraph").versionRef("classgraph-version") + library("assertj-core", "org.assertj", "assertj-core").versionRef("assertj-version") } + } } From 4cad0070fd64e3015aa727844544a13ca6676191 Mon Sep 17 00:00:00 2001 From: Hendrik Ebbers Date: Mon, 17 Apr 2023 13:11:09 +0200 Subject: [PATCH 3/6] javadoc Signed-off-by: Hendrik Ebbers --- .../AbstractEnumConfigConverter.java | 10 +++++++++ .../config/converter/AccountIDConverter.java | 3 +++ .../config/converter/ContractIDConverter.java | 3 +++ .../spi/config/converter/FileIDConverter.java | 3 +++ .../HederaFunctionalityConverter.java | 5 +++-- .../config/converter/ProfileConverter.java | 3 +++ .../converter/SidecarTypeConverter.java | 5 +++++ .../node/app/config/converter/ClassCheck.java | 22 ------------------- .../CongestionMultipliersConverter.java | 3 +++ .../EntityScaleFactorsConverter.java | 3 +++ .../config/converter/EntityTypeConverter.java | 5 +++++ .../converter/KnownBlockValuesConverter.java | 3 +++ .../LegacyContractIdActivationsConverter.java | 3 +++ .../converter/MapAccessTypeConverter.java | 5 +++++ .../converter/RecomputeTypeConverter.java | 5 +++++ .../converter/ScaleFactorConverter.java | 3 +++ .../PropertySourceBasedConfigSource.java | 8 +++++++ 17 files changed, 68 insertions(+), 24 deletions(-) delete mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java index 523c273ab548..92cbfc842ce8 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverter.java @@ -20,6 +20,11 @@ import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Objects; +/** + * Abstract class to support {@link ConfigConverter} for {@link Enum} types. + * + * @param type of the enum + */ public abstract class AbstractEnumConfigConverter> implements ConfigConverter { @Override @@ -32,6 +37,11 @@ public E convert(final String value) throws IllegalArgumentException, NullPointe return Enum.valueOf(enumType, value); } + /** + * Returns the {@link Class} of the {@link Enum} type. + * + * @return the {@link Class} of the {@link Enum} type + */ @NonNull protected abstract Class getEnumType(); } diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java index e55237cbec79..e5b8508fc593 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/AccountIDConverter.java @@ -20,6 +20,9 @@ import com.swirlds.config.api.converter.ConfigConverter; import java.util.stream.Stream; +/** + * Config api {@link ConfigConverter} implementation for the type {@link AccountID}. + */ public class AccountIDConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java index f3b777012198..0b829f758b80 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ContractIDConverter.java @@ -20,6 +20,9 @@ import com.swirlds.config.api.converter.ConfigConverter; import java.util.stream.Stream; +/** + * Config api {@link ConfigConverter} implementation for the type {@link ContractID}. + */ public class ContractIDConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java index 50d136b42c38..ce014a4d423d 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/FileIDConverter.java @@ -20,6 +20,9 @@ import com.swirlds.config.api.converter.ConfigConverter; import java.util.stream.Stream; +/** + * Config api {@link ConfigConverter} implementation for the type {@link FileID}. + */ public class FileIDConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java index 703c02dca106..9a911cd642bf 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverter.java @@ -20,8 +20,9 @@ import com.swirlds.config.api.converter.ConfigConverter; /** - * Converter implementation for the config API to support {@link HederaFunctionality}. Based on - * https://github.com/hashgraph/hedera-services/issues/6106 we currently need to add ConfigConverter explicitly + * Config api {@link ConfigConverter} implementation for the type {@link HederaFunctionality}. Based on + * https://github.com/hashgraph/hedera-services/issues/6106 we need to add {@code implements ConfigConverter} to the + * class for now. */ public class HederaFunctionalityConverter extends AbstractEnumConfigConverter implements ConfigConverter { diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java index de1486cad1c3..f79cfe5339fc 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/ProfileConverter.java @@ -19,6 +19,9 @@ import com.hedera.node.app.spi.config.Profile; import com.swirlds.config.api.converter.ConfigConverter; +/** + * Config api {@link ConfigConverter} implementation for the type {@link Profile}. + */ public class ProfileConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java index 6d2f69cda83f..98946a4703cb 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverter.java @@ -20,6 +20,11 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; +/** + * Config api {@link ConfigConverter} implementation for the type {@link SidecarType}. Based on + * https://github.com/hashgraph/hedera-services/issues/6106 we need to add {@code implements ConfigConverter} to the + * class for now. + */ public class SidecarTypeConverter extends AbstractEnumConfigConverter implements ConfigConverter { diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java deleted file mode 100644 index d709a80d796b..000000000000 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ClassCheck.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2023 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hedera.node.app.config.converter; - -public class ClassCheck { - - void foo() {} -} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java index e31119b062fc..e2f12cb290a6 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/CongestionMultipliersConverter.java @@ -19,6 +19,9 @@ import com.hedera.node.app.service.mono.fees.calculation.CongestionMultipliers; import com.swirlds.config.api.converter.ConfigConverter; +/** + * Config api {@link ConfigConverter} implementation for the type {@link CongestionMultipliers}. + */ public class CongestionMultipliersConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java index 56b184dbaae2..5751dca7c66c 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityScaleFactorsConverter.java @@ -19,6 +19,9 @@ import com.hedera.node.app.service.mono.fees.calculation.EntityScaleFactors; import com.swirlds.config.api.converter.ConfigConverter; +/** + * Config api {@link ConfigConverter} implementation for the type {@link EntityScaleFactors}. + */ public class EntityScaleFactorsConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java index c8c0271ee967..f17a327b645c 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/EntityTypeConverter.java @@ -21,6 +21,11 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; +/** + * Config api {@link ConfigConverter} implementation for the type {@link EntityType}. Based on + * https://github.com/hashgraph/hedera-services/issues/6106 we need to add {@code implements ConfigConverter} to the + * class for now. + */ public class EntityTypeConverter extends AbstractEnumConfigConverter implements ConfigConverter { diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java index de6e68e7b8e6..ebacab5ac2cf 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/KnownBlockValuesConverter.java @@ -19,6 +19,9 @@ import com.hedera.node.app.hapi.utils.sysfiles.domain.KnownBlockValues; import com.swirlds.config.api.converter.ConfigConverter; +/** + * Config api {@link ConfigConverter} implementation for the type {@link KnownBlockValues}. + */ public class KnownBlockValuesConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java index a8d008b6c4bc..79e556cac9bf 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/LegacyContractIdActivationsConverter.java @@ -19,6 +19,9 @@ import com.hedera.node.app.service.mono.keys.LegacyContractIdActivations; import com.swirlds.config.api.converter.ConfigConverter; +/** + * Config api {@link ConfigConverter} implementation for the type {@link LegacyContractIdActivations}. + */ public class LegacyContractIdActivationsConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java index cdbf34e4989c..47abe883a375 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/MapAccessTypeConverter.java @@ -21,6 +21,11 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; +/** + * Config api {@link ConfigConverter} implementation for the type {@link MapAccessType}. Based on + * https://github.com/hashgraph/hedera-services/issues/6106 we need to add {@code implements ConfigConverter} to the + * class for now. + */ public class MapAccessTypeConverter extends AbstractEnumConfigConverter implements ConfigConverter { @NonNull diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java index fead6b476e32..65ccd9a9a035 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/RecomputeTypeConverter.java @@ -21,6 +21,11 @@ import com.swirlds.config.api.converter.ConfigConverter; import edu.umd.cs.findbugs.annotations.NonNull; +/** + * Config api {@link ConfigConverter} implementation for the type {@link RecomputeType}. Based on + * https://github.com/hashgraph/hedera-services/issues/6106 we need to add {@code implements ConfigConverter} to the + * class for now. + */ public class RecomputeTypeConverter extends AbstractEnumConfigConverter implements ConfigConverter { diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java index a321c5b74df3..5e9be55f207b 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/converter/ScaleFactorConverter.java @@ -19,6 +19,9 @@ import com.hedera.node.app.hapi.utils.sysfiles.domain.throttling.ScaleFactor; import com.swirlds.config.api.converter.ConfigConverter; +/** + * Config api {@link ConfigConverter} implementation for the type {@link ScaleFactor}. + */ public class ScaleFactorConverter implements ConfigConverter { @Override diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java index 45ded0c0204d..983fc895367b 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/config/source/PropertySourceBasedConfigSource.java @@ -24,10 +24,18 @@ import java.util.Objects; import java.util.Set; +/** + * A {@link ConfigSource} that wraps a {@link PropertySource} and redirects all calls to the {@link PropertySource}. + */ public class PropertySourceBasedConfigSource implements ConfigSource { private final PropertySource propertySource; + /** + * Creates a new instance + * + * @param propertySource the property source + */ public PropertySourceBasedConfigSource(@NonNull final PropertySource propertySource) { this.propertySource = Objects.requireNonNull(propertySource, "propertySource"); } From 7f4b21facc00544aeb51af94aae7c5363d22dfdf Mon Sep 17 00:00:00 2001 From: Hendrik Ebbers Date: Mon, 17 Apr 2023 14:10:34 +0200 Subject: [PATCH 4/6] ParameterizedTest fixed Signed-off-by: Hendrik Ebbers --- .../node/app/spi/config/converter/AccountIDConverterTest.java | 2 -- .../node/app/spi/config/converter/ContractIDConverterTest.java | 2 -- .../node/app/spi/config/converter/FileIDConverterTest.java | 2 -- .../node/app/spi/config/converter/ProfileConverterTest.java | 1 - 4 files changed, 7 deletions(-) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java index a4e8d96b904b..a1d1e4414ee8 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java @@ -35,7 +35,6 @@ void testNullParam() { assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } - @Test @ParameterizedTest @ValueSource( strings = { @@ -49,7 +48,6 @@ void testAllNotParseable(final String input) { assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } - @Test @Disabled @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java index 16e9e835c3d8..f1edfc6bb0dc 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java @@ -35,7 +35,6 @@ void testNullParam() { assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } - @Test @ParameterizedTest @ValueSource( strings = { @@ -49,7 +48,6 @@ void testAllNotParseable(final String input) { assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } - @Test @Disabled @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java index 8329626d53d0..0434cd35222f 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java @@ -35,7 +35,6 @@ void testNullParam() { assertThatThrownBy(() -> converter.convert(null)).isInstanceOf(NullPointerException.class); } - @Test @ParameterizedTest @ValueSource( strings = { @@ -49,7 +48,6 @@ void testAllNotParseable(final String input) { assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } - @Test @Disabled @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java index 2d1013344b4f..fd60b28413bd 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ProfileConverterTest.java @@ -44,7 +44,6 @@ void testInvalidParam() { assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } - @Test @ParameterizedTest @CsvSource({ "DEV, DEV", From 9dd1913a63d201d34ab0aad4a307c346cd8e4659 Mon Sep 17 00:00:00 2001 From: Hendrik Ebbers Date: Mon, 17 Apr 2023 14:35:49 +0200 Subject: [PATCH 5/6] ParameterizedTest fixed Signed-off-by: Hendrik Ebbers --- .../node/app/spi/config/converter/AccountIDConverterTest.java | 2 +- .../app/spi/config/converter/ContractIDConverterTest.java | 2 +- .../node/app/spi/config/converter/FileIDConverterTest.java | 2 +- .../hedera/node/app/config/PropertySourceBasedConfigTest.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java index a1d1e4414ee8..c395e0489e33 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java @@ -88,6 +88,6 @@ void testLongValues() { assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); - assertThat(result.accountNum()).isEqualTo(0); + assertThat(result.accountNum()).isZero(); } } diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java index f1edfc6bb0dc..56ea472e67c3 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/ContractIDConverterTest.java @@ -88,6 +88,6 @@ void testLongValues() { assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); - assertThat(result.contractNum()).isEqualTo(0); + assertThat(result.contractNum()).isZero(); } } diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java index 0434cd35222f..64115f08d66e 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/FileIDConverterTest.java @@ -88,6 +88,6 @@ void testLongValues() { assertThat(result).isNotNull(); assertThat(result.shardNum()).isEqualTo(Long.MAX_VALUE); assertThat(result.realmNum()).isEqualTo(Long.MAX_VALUE); - assertThat(result.fileNum()).isEqualTo(0); + assertThat(result.fileNum()).isZero(); } } diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java index e711bc1c5e44..c530faea2b7c 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/config/PropertySourceBasedConfigTest.java @@ -61,7 +61,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class PropertySourceBasedConfigTest { +class PropertySourceBasedConfigTest { @Mock(strictness = Strictness.LENIENT) private PropertySource propertySource; @@ -91,7 +91,7 @@ void configureMockForConfigData() { } @Test - public void testConfig() { + void testConfig() { // given final Configuration configuration = ConfigurationBuilder.create() .withConverter(new CongestionMultipliersConverter()) From 8f3da9834ac4d755a844eaf483ad0898a09c3e31 Mon Sep 17 00:00:00 2001 From: Hendrik Ebbers Date: Fri, 21 Apr 2023 16:05:18 +0200 Subject: [PATCH 6/6] based on review Signed-off-by: Hendrik Ebbers --- .../converter/AbstractEnumConfigConverterTest.java | 11 +++++++---- .../spi/config/converter/AccountIDConverterTest.java | 6 ++++++ .../converter/HederaFunctionalityConverterTest.java | 11 +++++++---- .../config/converter/SidecarTypeConverterTest.java | 11 +++++++---- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java index 0a38ee59125e..e94ae8189d5a 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AbstractEnumConfigConverterTest.java @@ -26,6 +26,8 @@ import java.lang.annotation.ElementType; import java.lang.annotation.RetentionPolicy; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; class AbstractEnumConfigConverterTest { @@ -73,16 +75,17 @@ void testInvalidValue() { assertThatThrownBy(() -> converter.convert("not-supported-value")).isInstanceOf(IllegalArgumentException.class); } - @Test - void testValidValue() { + @ParameterizedTest + @EnumSource(value = RetentionPolicy.class) + void testValidValue(final RetentionPolicy value) { // given final RetentionPolicyConverter converter = new RetentionPolicyConverter(); // when - final RetentionPolicy source = converter.convert("SOURCE"); + final RetentionPolicy source = converter.convert(value.name()); // then - assertThat(source).isEqualTo(RetentionPolicy.SOURCE); + assertThat(source).isEqualTo(value); } @Test diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java index c395e0489e33..5e6ba491973b 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/AccountIDConverterTest.java @@ -48,6 +48,12 @@ void testAllNotParseable(final String input) { assertThatThrownBy(() -> converter.convert(input)).isInstanceOf(IllegalArgumentException.class); } + /** + * The given tests does not work. From my point of view the expected behavior is to throw an exception but the + * values would be converted without an issue. We should have a look at this in future. + * + * @param input + */ @Disabled @ParameterizedTest @ValueSource(strings = {"1.2.3.", "1.2.3.."}) diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java index 43b481d44c84..b9600a47bfac 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/HederaFunctionalityConverterTest.java @@ -21,6 +21,8 @@ import com.hedera.hapi.node.base.HederaFunctionality; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; class HederaFunctionalityConverterTest { @@ -42,15 +44,16 @@ void testInvalidParam() { assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } - @Test - void testValidParam() { + @ParameterizedTest + @EnumSource(HederaFunctionality.class) + void testValidParam(final HederaFunctionality functionality) { // given final HederaFunctionalityConverter converter = new HederaFunctionalityConverter(); // when - final HederaFunctionality cryptoTransfer = converter.convert("CRYPTO_TRANSFER"); + final HederaFunctionality cryptoTransfer = converter.convert(functionality.name()); // then - assertThat(cryptoTransfer).isEqualTo(HederaFunctionality.CRYPTO_TRANSFER); + assertThat(cryptoTransfer).isEqualTo(functionality); } } diff --git a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java index 39fb264947e3..85f1de6bf6a4 100644 --- a/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java +++ b/hedera-node/hedera-app-spi/src/test/java/com/hedera/node/app/spi/config/converter/SidecarTypeConverterTest.java @@ -21,6 +21,8 @@ import com.hedera.hapi.streams.SidecarType; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; class SidecarTypeConverterTest { @@ -42,15 +44,16 @@ void testInvalidParam() { assertThatThrownBy(() -> converter.convert("null")).isInstanceOf(IllegalArgumentException.class); } - @Test - void testValidParam() { + @ParameterizedTest + @EnumSource(SidecarType.class) + void testValidParam(final SidecarType value) { // given final SidecarTypeConverter converter = new SidecarTypeConverter(); // when - final SidecarType sidecarType = converter.convert("SIDECAR_TYPE_UNKNOWN"); + final SidecarType sidecarType = converter.convert(value.name()); // then - assertThat(sidecarType).isEqualTo(SidecarType.SIDECAR_TYPE_UNKNOWN); + assertThat(sidecarType).isEqualTo(value); } }