Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #495: require toString() for types used as aggregate identifier
Aggregate field annotated with @EntityID or @AggregateIdentifier should override Object.toString()\ - StubAggregate classes now use UUID or String as identifier type - java.lang.Object is no longer supported as identifier type
- Loading branch information
Showing
10 changed files
with
114 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core/src/test/java/org/axonframework/common/IdentifierValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
package org.axonframework.common; | |||
|
|||
import org.junit.Test; | |||
|
|||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
|
|||
public class IdentifierValidatorTest { | |||
|
|||
private final IdentifierValidator validator = IdentifierValidator.getInstance(); | |||
|
|||
@Test | |||
public void boxedPrimitivesAreValidIdentifiers() { | |||
assertTrue(validator.isValidIdentifier(Long.class)); | |||
assertTrue(validator.isValidIdentifier(Integer.class)); | |||
assertTrue(validator.isValidIdentifier(Double.class)); | |||
assertTrue(validator.isValidIdentifier(Short.class)); | |||
} | |||
|
|||
@Test | |||
public void stringIsValidIdentifier() { | |||
assertTrue(validator.isValidIdentifier(CharSequence.class)); | |||
} | |||
|
|||
@Test | |||
public void typeWithoutToStringIsNotAccepted() { | |||
assertFalse(validator.isValidIdentifier(CustomType.class)); | |||
} | |||
|
|||
@Test | |||
public void typeWithOverriddenToString() { | |||
assertTrue(validator.isValidIdentifier(CustomType2.class)); | |||
} | |||
|
|||
private static class CustomType { | |||
} | |||
|
|||
private static class CustomType2 { | |||
@Override | |||
public String toString() { | |||
return "ok"; | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters