Skip to content

Commit

Permalink
fix: Fix handling of improper camel case (e.g. TokenID vs TokenId) in…
Browse files Browse the repository at this point in the history
… proto message names

* Added a test with incorrect camel case usage that fails
* Also updated the Java language version to 21.

Signed-off-by: Joseph Sinclair <[email protected]>
  • Loading branch information
jsync-swirlds committed Jan 29, 2024
1 parent d47beaf commit 5314bd1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ plugins {
group = "com.hedera.pbj"

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
vendor.set(JvmVendorSpec.ADOPTIUM)
}

Expand Down
23 changes: 23 additions & 0 deletions pbj-integration-tests/src/main/proto/comparable.proto
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,28 @@ message LimitedComparableTestWithOneOf {
string oneOfText = 10;
ComparableSubObj oneOfSubObject = 12;
}
}

/**
* Help to encounter the error found in issue #180 by providing an enum with a name
* that has unusual "almost" camel case. The odd case of "ENum" is deliberate here.
*/
enum OddCaseENum {
UP = 0;
DOWN = 1;
CHARM = 2;
STRANGE = 3;
TOP = 4;
BOTTOM = 5;
}

/**
* This exercises the error found in issue #180 by including fields of the
* problematic message types.
*/
// <<<pbj.comparable = "test_comparable_value, test_enum_value, simple_stringValue" >>>
message ComparableContainsWrongCase {
ComparableWrongCaseID test_comparable_value = 1;
OddCaseENum test_enum_value = 2;
string simple_stringValue = 3;
}
13 changes: 12 additions & 1 deletion pbj-integration-tests/src/main/proto/everything.proto
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,15 @@ message InnerEverything {
google.protobuf.BytesValue bytesBoxedOneOf = 100025;
google.protobuf.StringValue stringBoxedOneOf = 100026;
}
}
}

/**
* Example of a message which is named <strong>almost</strong> like a Java class, but not quite.
* This helps test the error originally found in issue #180.
* Placed here to ensure comparable works across imported files.
*/
// <<<pbj.comparable = "subMessageCMP, sub_message_two" >>>
message ComparableWrongCaseID {
TimestampTest subMessageCMP = 1;
Suit sub_message_two = 2;
}
13 changes: 7 additions & 6 deletions pbj-integration-tests/src/main/proto/timestampTest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ package proto;
/** Test issue 87 */
/** Test issue 87 */

/*-
*
/*
*
* Hedera Network Services Protobuf
*
*
* Copyright (C) 2018 - 2021 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
Expand All @@ -22,7 +22,7 @@ package proto;
* 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.
*
*
*/

option java_package = "com.hedera.pbj.test.proto.java";
Expand All @@ -32,7 +32,9 @@ option java_multiple_files = true;
/**
* An exact date and time. This is the same data structure as the protobuf Timestamp.proto (see the
* comments in https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto)
* We add comparable here to expand testing of that feature
*/
// <<<pbj.comparable = "seconds,nanos" >>>
message TimestampTest {
/**
* Number of complete seconds since the start of the epoch
Expand All @@ -54,4 +56,3 @@ message TimestampTestSeconds {
*/
int64 seconds = 1;
}

0 comments on commit 5314bd1

Please sign in to comment.