Skip to content

Commit eb1dd65

Browse files
committed
Add test for non-boolean fields with 'is' prefix
1 parent d70675a commit eb1dd65

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed
Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323

2424
/**
2525
* Tests that TableSchema.fromImmutableClass() works correctly with immutable classes
26-
* that have boolean fields using "is" prefix.
26+
* that have fields using "is" prefix.
2727
*/
28-
public class ImmutableBooleanIsPrefixTest {
28+
public class TableSchemaImmutableIsPrefixTest {
2929

30+
// Test class for boolean fields with "is" prefix
3031
@DynamoDbImmutable(builder = Car.Builder.class)
3132
public static final class Car {
3233
private final String licensePlate;
@@ -92,4 +93,70 @@ public void fromImmutableClass_withIsPrefixBooleanSetters_shouldCreateSchemaSucc
9293
"licensePlate", "rusty", "impounded"
9394
);
9495
}
96+
97+
// Test class for non-boolean fields with "is" prefix
98+
@DynamoDbImmutable(builder = Vehicle.Builder.class)
99+
public static final class Vehicle {
100+
private final String licensePlate;
101+
private final String isModel;
102+
private final Integer isYear;
103+
104+
private Vehicle(Builder b) {
105+
this.licensePlate = b.licensePlate;
106+
this.isModel = b.isModel;
107+
this.isYear = b.isYear;
108+
}
109+
110+
@DynamoDbPartitionKey
111+
public String licensePlate() {
112+
return this.licensePlate;
113+
}
114+
115+
public String isModel() {
116+
return this.isModel;
117+
}
118+
119+
public Integer isYear() {
120+
return this.isYear;
121+
}
122+
123+
public static final class Builder {
124+
private String licensePlate;
125+
private String isModel;
126+
private Integer isYear;
127+
128+
public Builder licensePlate(String licensePlate) {
129+
this.licensePlate = licensePlate;
130+
return this;
131+
}
132+
133+
public Builder isModel(String isModel) {
134+
this.isModel = isModel;
135+
return this;
136+
}
137+
138+
public Builder isYear(Integer isYear) {
139+
this.isYear = isYear;
140+
return this;
141+
}
142+
143+
public Vehicle build() {
144+
return new Vehicle(this);
145+
}
146+
}
147+
}
148+
149+
@Test
150+
public void fromImmutableClass_withIsPrefixNonBooleanFields_shouldNotNormalizeIsPrefix() {
151+
TableSchema<Vehicle> schema = TableSchema.fromImmutableClass(Vehicle.class);
152+
153+
// Verify the schema was created successfully
154+
assertThat(schema).isNotNull();
155+
assertThat(schema.itemType().rawClass()).isEqualTo(Vehicle.class);
156+
157+
// Verify non-boolean "is" prefix fields are not normalized
158+
assertThat(schema.attributeNames()).containsExactlyInAnyOrder(
159+
"licensePlate", "isModel", "isYear"
160+
);
161+
}
95162
}

0 commit comments

Comments
 (0)