@Test void testResolveTarget_WithAnnotatedFields_NonNumericVersion() { final UUID aggregateIdentifier = UUID.randomUUID(); final Object version = "abc"; CommandMessage<Object> command = asCommandMessage(new FieldAnnotatedCommand(aggregateIdentifier, version)); assertThrows(IllegalArgumentException.class, () -> testSubject.resolveTarget(command)); }
@Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); }
AnnotationCommandTargetResolver implements CommandTargetResolver { @Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); } }
AnnotationCommandTargetResolver implements CommandTargetResolver { @Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); } @Deprecated  AnnotationCommandTargetResolver(); protected  AnnotationCommandTargetResolver(Builder builder); }
AnnotationCommandTargetResolver implements CommandTargetResolver { @Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); } @Deprecated  AnnotationCommandTargetResolver(); protected  AnnotationCommandTargetResolver(Builder builder); static final Builder builder(); @Override VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command); @Override String toString(); }
AnnotationCommandTargetResolver implements CommandTargetResolver { @Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); } @Deprecated  AnnotationCommandTargetResolver(); protected  AnnotationCommandTargetResolver(Builder builder); static final Builder builder(); @Override VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command); @Override String toString();  }