repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/hostTarget/HostTargetBuilder.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.hostTarget;
/**Constructs a {@link HostTarget} object. To create a {@link HostTarget} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface HostTargetBuilder {
public static HostTargetBuilder getDefault() {
return new DefaultHostTargetBuilder();
}
/**Constructs a new {@link HostTarget} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link HostTarget} object.
* Make sure that the COMMAND of the message equals "HOSTTARGET"
*
* @param message The message we received from Twitch
* @return A {@link HostTarget}, or <code>null</code> if a {@link HostTarget} could not be created
*/ | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/hostTarget/HostTargetBuilder.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.hostTarget;
/**Constructs a {@link HostTarget} object. To create a {@link HostTarget} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface HostTargetBuilder {
public static HostTargetBuilder getDefault() {
return new DefaultHostTargetBuilder();
}
/**Constructs a new {@link HostTarget} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link HostTarget} object.
* Make sure that the COMMAND of the message equals "HOSTTARGET"
*
* @param message The message we received from Twitch
* @return A {@link HostTarget}, or <code>null</code> if a {@link HostTarget} could not be created
*/ | public HostTarget build(TwitchMessage message); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
| // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
| private final Optional<Raid> raid; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid; | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid; | private final Optional<Subscription> subscription; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription; | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription; | private final Optional<Ritual> ritual; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription;
private final Optional<Ritual> ritual;
private final String systemMessage;
private final String message; | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription;
private final Optional<Ritual> ritual;
private final String systemMessage;
private final String message; | private final List<Emote> emotes; |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/mode/TestMode.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
| // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
// Path: src/test/java/com/gikk/twirk/types/mode/TestMode.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
| public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/mode/TestMode.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
// Path: src/test/java/com/gikk/twirk/types/mode/TestMode.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{ | TestResult resGain = test.assign(TestMode::testGainMod); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/mode/TestMode.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{
TestResult resGain = test.assign(TestMode::testGainMod);
twirkInput.accept(GAIN_MOD);
resGain.await();
TestResult resLost = test.assign(TestMode::testLostMod);
twirkInput.accept(LOST_MOD);
resLost.await();
}
private static boolean testGainMod(Mode mode){ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
// Path: src/test/java/com/gikk/twirk/types/mode/TestMode.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{
TestResult resGain = test.assign(TestMode::testGainMod);
twirkInput.accept(GAIN_MOD);
resGain.await();
TestResult resLost = test.assign(TestMode::testLostMod);
twirkInput.accept(LOST_MOD);
resLost.await();
}
private static boolean testGainMod(Mode mode){ | doTest(mode, GAIN_MOD, MODE_EVENT.GAINED_MOD, "gikkbot"); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/ | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java
import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/ | public Optional<Subscription> getSubscription(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/
public Optional<Subscription> getSubscription();
/**Tells whether this Usernotice is a raid alert.
*
* @return {@code true} if this is a raid alert
*/
public boolean isRaid();
/**Retrieves the Raid object. The Optional object wraps the
* Raid object (as an alternative to returning {@code null}).
*
* @return the Raid
*/ | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java
import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/
public Optional<Subscription> getSubscription();
/**Tells whether this Usernotice is a raid alert.
*
* @return {@code true} if this is a raid alert
*/
public boolean isRaid();
/**Retrieves the Raid object. The Optional object wraps the
* Raid object (as an alternative to returning {@code null}).
*
* @return the Raid
*/ | public Optional<Raid> getRaid(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/privmsg/PrivateMessage.java | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/cheer/Cheer.java
// public interface Cheer {
// public int getBits();
// public String getMessage();
// public String getImageURL(CheerTheme theme, CheerType type, CheerSize size);
// }
| import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.cheer.Cheer;
import java.util.List; | package com.gikk.twirk.types.privmsg;
/**
*
* @author Gikkman
*/
public interface PrivateMessage extends AbstractEmoteMessage{
/**Tells whether this message was a cheer event or not.
*
* @return {@code true} if the message contains bits, <code>false</code> otherwise
*/
public boolean isCheer();
/**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
* The list might be empty, if the message contained no cheers.
*
* @return List of emotes (might be empty)
*/ | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/cheer/Cheer.java
// public interface Cheer {
// public int getBits();
// public String getMessage();
// public String getImageURL(CheerTheme theme, CheerType type, CheerSize size);
// }
// Path: src/main/java/com/gikk/twirk/types/privmsg/PrivateMessage.java
import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.cheer.Cheer;
import java.util.List;
package com.gikk.twirk.types.privmsg;
/**
*
* @author Gikkman
*/
public interface PrivateMessage extends AbstractEmoteMessage{
/**Tells whether this message was a cheer event or not.
*
* @return {@code true} if the message contains bits, <code>false</code> otherwise
*/
public boolean isCheer();
/**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
* The list might be empty, if the message contained no cheers.
*
* @return List of emotes (might be empty)
*/ | public List<Cheer> getCheers(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/hostTarget/DefaultHostTargetBuilder.java | // Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.enums.HOSTTARGET_MODE;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.hostTarget;
class DefaultHostTargetBuilder implements HostTargetBuilder {
HOSTTARGET_MODE mode;
String target;
int viwerAmount;
String rawLine;
@Override | // Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/hostTarget/DefaultHostTargetBuilder.java
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.hostTarget;
class DefaultHostTargetBuilder implements HostTargetBuilder {
HOSTTARGET_MODE mode;
String target;
int viwerAmount;
String rawLine;
@Override | public HostTarget build(TwitchMessage message) { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/mode/DefaultModeBuilder.java | // Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.mode;
class DefaultModeBuilder implements ModeBuilder{
MODE_EVENT event;
String user;
String rawLine;
@Override | // Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/mode/DefaultModeBuilder.java
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.mode;
class DefaultModeBuilder implements ModeBuilder{
MODE_EVENT event;
String user;
String rawLine;
@Override | public Mode build(TwitchMessage message) { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java
import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override | public ClearMsg build(TwitchMessage twitchMessage) { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override
public ClearMsg build(TwitchMessage twitchMessage) {
this.rawLine = twitchMessage.getRaw();
| // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java
import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override
public ClearMsg build(TwitchMessage twitchMessage) {
this.rawLine = twitchMessage.getRaw();
| TagMap r = twitchMessage.getTagMap(); |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderFactory.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
| import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekStateLoaderFactory {
private final WeekStateCalculatorFactory weekStateCalculatorFactory;
public WeekStateLoaderFactory(@NonNull WeekStateCalculatorFactory weekStateCalculatorFactory) {
this.weekStateCalculatorFactory = weekStateCalculatorFactory;
}
| // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderFactory.java
import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekStateLoaderFactory {
private final WeekStateCalculatorFactory weekStateCalculatorFactory;
public WeekStateLoaderFactory(@NonNull WeekStateCalculatorFactory weekStateCalculatorFactory) {
this.weekStateCalculatorFactory = weekStateCalculatorFactory;
}
| public @NonNull WeekStateLoader create(@NonNull Week week, |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderFactory.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
| import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekStateLoaderFactory {
private final WeekStateCalculatorFactory weekStateCalculatorFactory;
public WeekStateLoaderFactory(@NonNull WeekStateCalculatorFactory weekStateCalculatorFactory) {
this.weekStateCalculatorFactory = weekStateCalculatorFactory;
}
public @NonNull WeekStateLoader create(@NonNull Week week, | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderFactory.java
import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekStateLoaderFactory {
private final WeekStateCalculatorFactory weekStateCalculatorFactory;
public WeekStateLoaderFactory(@NonNull WeekStateCalculatorFactory weekStateCalculatorFactory) {
this.weekStateCalculatorFactory = weekStateCalculatorFactory;
}
public @NonNull WeekStateLoader create(@NonNull Week week, | @NonNull Consumer<WeekState> onLoadedCallback) { |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekAdapter.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekTimesView.java
// public interface OnDayClickListener {
// void onClick(View v, DayOfWeek day);
// }
| import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import android.content.Context;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import org.zephyrsoft.trackworktime.weektimes.WeekTimesView.OnDayClickListener;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekAdapter extends RecyclerView.Adapter<WeekTimesViewHolder> {
private final WeekStateLoaderManager weekStateLoaderManager;
private final LayoutParams LAYOUT_PARAMS = new LayoutParams(MATCH_PARENT, MATCH_PARENT); | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekTimesView.java
// public interface OnDayClickListener {
// void onClick(View v, DayOfWeek day);
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekAdapter.java
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import android.content.Context;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import org.zephyrsoft.trackworktime.weektimes.WeekTimesView.OnDayClickListener;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekAdapter extends RecyclerView.Adapter<WeekTimesViewHolder> {
private final WeekStateLoaderManager weekStateLoaderManager;
private final LayoutParams LAYOUT_PARAMS = new LayoutParams(MATCH_PARENT, MATCH_PARENT); | private final OnDayClickListener onDayClickListener; |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekAdapter.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekTimesView.java
// public interface OnDayClickListener {
// void onClick(View v, DayOfWeek day);
// }
| import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import android.content.Context;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import org.zephyrsoft.trackworktime.weektimes.WeekTimesView.OnDayClickListener;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; | @Nullable OnDayClickListener onDayClickListener,
@Nullable OnClickListener onClickListener) {
this.weekStateLoaderManager = weekStateLoaderManager;
this.onDayClickListener = onDayClickListener;
this.onClickListener = onClickListener;
setHasStableIds(true);
}
@NonNull @Override
public WeekTimesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Context context = parent.getContext();
WeekTimesView weekTimesView = createView(context);
return new WeekTimesViewHolder(weekTimesView);
}
private WeekTimesView createView(Context context) {
WeekTimesView weekTimesView = new WeekTimesView(context);
weekTimesView.setLayoutParams(LAYOUT_PARAMS);
weekTimesView.setOnDayClickListener(onDayClickListener);
weekTimesView.setOnClickListener(onClickListener);
return weekTimesView;
}
@Override
public void onBindViewHolder(@NonNull WeekTimesViewHolder holder, int position) {
Week week = WeekIndexConverter.getWeekForIndex(position);
int requestId = position;
// Cancel request before starting new one. It's possible same week is still being loaded,
// but holder hasn't been recycled yet.
weekStateLoaderManager.cancelRequest(requestId); | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekTimesView.java
// public interface OnDayClickListener {
// void onClick(View v, DayOfWeek day);
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekAdapter.java
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import android.content.Context;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import org.zephyrsoft.trackworktime.weektimes.WeekTimesView.OnDayClickListener;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
@Nullable OnDayClickListener onDayClickListener,
@Nullable OnClickListener onClickListener) {
this.weekStateLoaderManager = weekStateLoaderManager;
this.onDayClickListener = onDayClickListener;
this.onClickListener = onClickListener;
setHasStableIds(true);
}
@NonNull @Override
public WeekTimesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Context context = parent.getContext();
WeekTimesView weekTimesView = createView(context);
return new WeekTimesViewHolder(weekTimesView);
}
private WeekTimesView createView(Context context) {
WeekTimesView weekTimesView = new WeekTimesView(context);
weekTimesView.setLayoutParams(LAYOUT_PARAMS);
weekTimesView.setOnDayClickListener(onDayClickListener);
weekTimesView.setOnClickListener(onClickListener);
return weekTimesView;
}
@Override
public void onBindViewHolder(@NonNull WeekTimesViewHolder holder, int position) {
Week week = WeekIndexConverter.getWeekForIndex(position);
int requestId = position;
// Cancel request before starting new one. It's possible same week is still being loaded,
// but holder hasn't been recycled yet.
weekStateLoaderManager.cancelRequest(requestId); | LiveData<WeekState> weekState = weekStateLoaderManager.requestWeekState(week, requestId); |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekTimesView.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
| import org.zephyrsoft.trackworktime.model.WeekState.DayRowState;
import org.zephyrsoft.trackworktime.model.WeekState.SummaryRowState;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.asynclayoutinflater.view.AsyncLayoutInflater;
import org.pmw.tinylog.Logger;
import org.threeten.bp.DayOfWeek;
import org.zephyrsoft.trackworktime.R;
import org.zephyrsoft.trackworktime.databinding.WeekTableBinding;
import org.zephyrsoft.trackworktime.model.WeekState; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekTimesView extends LinearLayout {
private WeekState weekState;
private TableLayout weekTable = null;
private WeekTableBinding binding;
public WeekTimesView(@NonNull Context context) {
super(context);
startLayoutLoading();
}
private void startLayoutLoading() {
new AsyncLayoutInflater(getContext()).inflate(R.layout.week_table,this, ((view, resid, parent) -> {
binding = WeekTableBinding.bind(view);
parent.addView(binding.getRoot());
onViewReady();
}));
}
private void onViewReady() {
weekTable = binding.weekTable;
if(isDataSet()) {
loadWeekState();
}
}
/** Interface for callback when clicking on day **/
public interface OnDayClickListener {
void onClick(View v, DayOfWeek day);
}
private OnDayClickListener onDayClickListener;
public void setOnDayClickListener(OnDayClickListener onDayClickListener) {
this.onDayClickListener = onDayClickListener;
}
private boolean isDataSet() {
return weekState != null;
}
public void clearWeekState() {
setWeekState(new WeekState());
}
public void setWeekState(@NonNull WeekState weekState) {
this.weekState = weekState;
if(isViewReady()) {
loadWeekState();
}
}
private boolean isViewReady() {
return weekTable != null;
}
private void loadWeekState() {
if(!isDataSet()) {
Logger.warn("Loading weekState when data was not set");
return;
}
binding.topLeftCorner.setText(weekState.topLeftCorner);
for (DayOfWeek day : DayOfWeek.values()) { | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekTimesView.java
import org.zephyrsoft.trackworktime.model.WeekState.DayRowState;
import org.zephyrsoft.trackworktime.model.WeekState.SummaryRowState;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.asynclayoutinflater.view.AsyncLayoutInflater;
import org.pmw.tinylog.Logger;
import org.threeten.bp.DayOfWeek;
import org.zephyrsoft.trackworktime.R;
import org.zephyrsoft.trackworktime.databinding.WeekTableBinding;
import org.zephyrsoft.trackworktime.model.WeekState;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
public class WeekTimesView extends LinearLayout {
private WeekState weekState;
private TableLayout weekTable = null;
private WeekTableBinding binding;
public WeekTimesView(@NonNull Context context) {
super(context);
startLayoutLoading();
}
private void startLayoutLoading() {
new AsyncLayoutInflater(getContext()).inflate(R.layout.week_table,this, ((view, resid, parent) -> {
binding = WeekTableBinding.bind(view);
parent.addView(binding.getRoot());
onViewReady();
}));
}
private void onViewReady() {
weekTable = binding.weekTable;
if(isDataSet()) {
loadWeekState();
}
}
/** Interface for callback when clicking on day **/
public interface OnDayClickListener {
void onClick(View v, DayOfWeek day);
}
private OnDayClickListener onDayClickListener;
public void setOnDayClickListener(OnDayClickListener onDayClickListener) {
this.onDayClickListener = onDayClickListener;
}
private boolean isDataSet() {
return weekState != null;
}
public void clearWeekState() {
setWeekState(new WeekState());
}
public void setWeekState(@NonNull WeekState weekState) {
this.weekState = weekState;
if(isViewReady()) {
loadWeekState();
}
}
private boolean isViewReady() {
return weekTable != null;
}
private void loadWeekState() {
if(!isDataSet()) {
Logger.warn("Loading weekState when data was not set");
return;
}
binding.topLeftCorner.setText(weekState.topLeftCorner);
for (DayOfWeek day : DayOfWeek.values()) { | DayRowState currentWeekRow = weekState.getRowForDay(day); |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/report/ReportPreviewActivity.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Report.java
// public final class Report implements Serializable {
// private final String name;
// private final String data;
//
// public Report(String name, String data) {
// this.name = name;
// this.data = data;
// }
//
// public @NonNull String getName() {
// return name;
// }
//
// public @NonNull String getData() {
// return data;
// }
//
// }
| import org.zephyrsoft.trackworktime.model.Report;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import org.apache.commons.lang3.StringUtils;
import org.pmw.tinylog.Logger;
import org.zephyrsoft.trackworktime.R;
import org.zephyrsoft.trackworktime.databinding.ReportPreviewBinding; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.report;
public class ReportPreviewActivity extends AppCompatActivity {
private static final String EXTRA_REPORT = "report";
private ReportPreviewBinding binding;
| // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Report.java
// public final class Report implements Serializable {
// private final String name;
// private final String data;
//
// public Report(String name, String data) {
// this.name = name;
// this.data = data;
// }
//
// public @NonNull String getName() {
// return name;
// }
//
// public @NonNull String getData() {
// return data;
// }
//
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/report/ReportPreviewActivity.java
import org.zephyrsoft.trackworktime.model.Report;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import org.apache.commons.lang3.StringUtils;
import org.pmw.tinylog.Logger;
import org.zephyrsoft.trackworktime.R;
import org.zephyrsoft.trackworktime.databinding.ReportPreviewBinding;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.report;
public class ReportPreviewActivity extends AppCompatActivity {
private static final String EXTRA_REPORT = "report";
private ReportPreviewBinding binding;
| public static Intent createIntent(@NonNull Context context, @NonNull Report report) { |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderManager.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
| import android.os.AsyncTask;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import java.util.concurrent.Executor; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
/**
* Manages loading of {@link WeekState}.
*/
public class WeekStateLoaderManager {
private static final Executor threadPool = AsyncTask.THREAD_POOL_EXECUTOR;
private final SparseArray<WeekStateLoader> weekStateLoaders = new SparseArray<>();
private final WeekStateLoaderFactory weekStateLoaderFactory;
public WeekStateLoaderManager(@NonNull WeekStateLoaderFactory weekStateLoaderFactory) {
this.weekStateLoaderFactory = weekStateLoaderFactory;
}
/**
* Request {@link WeekState}, that will be calculated async.
* @param week week to calculate {@link WeekState} for
* @param requestId request identifier, to identify specific async loader
* @return data reference, that will be updated, once {@link WeekState} is ready
*/ | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderManager.java
import android.os.AsyncTask;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import java.util.concurrent.Executor;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
/**
* Manages loading of {@link WeekState}.
*/
public class WeekStateLoaderManager {
private static final Executor threadPool = AsyncTask.THREAD_POOL_EXECUTOR;
private final SparseArray<WeekStateLoader> weekStateLoaders = new SparseArray<>();
private final WeekStateLoaderFactory weekStateLoaderFactory;
public WeekStateLoaderManager(@NonNull WeekStateLoaderFactory weekStateLoaderFactory) {
this.weekStateLoaderFactory = weekStateLoaderFactory;
}
/**
* Request {@link WeekState}, that will be calculated async.
* @param week week to calculate {@link WeekState} for
* @param requestId request identifier, to identify specific async loader
* @return data reference, that will be updated, once {@link WeekState} is ready
*/ | public @NonNull LiveData<WeekState> requestWeekState(@NonNull Week week, int requestId) { |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderManager.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
| import android.os.AsyncTask;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import java.util.concurrent.Executor; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
/**
* Manages loading of {@link WeekState}.
*/
public class WeekStateLoaderManager {
private static final Executor threadPool = AsyncTask.THREAD_POOL_EXECUTOR;
private final SparseArray<WeekStateLoader> weekStateLoaders = new SparseArray<>();
private final WeekStateLoaderFactory weekStateLoaderFactory;
public WeekStateLoaderManager(@NonNull WeekStateLoaderFactory weekStateLoaderFactory) {
this.weekStateLoaderFactory = weekStateLoaderFactory;
}
/**
* Request {@link WeekState}, that will be calculated async.
* @param week week to calculate {@link WeekState} for
* @param requestId request identifier, to identify specific async loader
* @return data reference, that will be updated, once {@link WeekState} is ready
*/ | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
//
// Path: app/src/main/java/org/zephyrsoft/trackworktime/model/WeekState.java
// public class WeekState {
//
// public enum HighlightType {
// NONE,
// REGULAR_FREE,
// FREE,
// CHANGED_TARGET_TIME
// }
//
// public static class DayRowState {
// public String label = "";
// public HighlightType labelHighlighted = HighlightType.NONE;
// public String in = "";
// public String out = "";
// public String worked = "";
// public String flexi = "";
//
// public boolean highlighted = false;
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + in + ", " + out + ", " + worked + ", " + flexi
// + ", highlighted: " + highlighted;
// }
// }
//
// public static class SummaryRowState {
// public String label = "";
// public String worked = "";
// public String flexi = "";
//
// @NonNull @Override
// public String toString() {
// return "values: " + label + ", " + worked + ", " + flexi;
// }
// }
//
// public String topLeftCorner = "";
// public final SummaryRowState totals = new SummaryRowState();
//
// private final DayRowState[] dayRowStates = {
// new DayRowState(), new DayRowState(), new DayRowState(), new DayRowState(),
// new DayRowState(), new DayRowState(), new DayRowState()
// };
//
// public DayRowState getRowForDay(DayOfWeek dayOfWeek) {
// return dayRowStates[dayOfWeek.ordinal()];
// }
//
// @NonNull @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(topLeftCorner); sb.append("\n");
//
// for (DayOfWeek day : DayOfWeek.values()) {
// sb.append(getRowForDay(day).toString());
// sb.append("\n");
// }
//
// sb.append(totals); sb.append("\n");
//
// return sb.toString();
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekStateLoaderManager.java
import android.os.AsyncTask;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import org.zephyrsoft.trackworktime.model.Week;
import org.zephyrsoft.trackworktime.model.WeekState;
import java.util.concurrent.Executor;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
/**
* Manages loading of {@link WeekState}.
*/
public class WeekStateLoaderManager {
private static final Executor threadPool = AsyncTask.THREAD_POOL_EXECUTOR;
private final SparseArray<WeekStateLoader> weekStateLoaders = new SparseArray<>();
private final WeekStateLoaderFactory weekStateLoaderFactory;
public WeekStateLoaderManager(@NonNull WeekStateLoaderFactory weekStateLoaderFactory) {
this.weekStateLoaderFactory = weekStateLoaderFactory;
}
/**
* Request {@link WeekState}, that will be calculated async.
* @param week week to calculate {@link WeekState} for
* @param requestId request identifier, to identify specific async loader
* @return data reference, that will be updated, once {@link WeekState} is ready
*/ | public @NonNull LiveData<WeekState> requestWeekState(@NonNull Week week, int requestId) { |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/options/FlexiIntervalPreference.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/FlexiReset.java
// public enum FlexiReset {
// NONE(1, Unit.NULL, "none"),
// DAILY(1, Unit.DAY, "daily"),
// WEEKLY(1, Unit.WEEK, "weekly"),
// MONTHLY(1, Unit.MONTH, "monthly"),
// QUARTERLY(3, Unit.MONTH, "quarterly"),
// HALF_YEARLY(6, Unit.MONTH, "half-yearly"),
// YEARLY(12, Unit.MONTH, "yearly");
//
// private final int intervalSize;
// private final Unit intervalUnit;
// private final String friendlyName;
//
// FlexiReset(@IntRange(from=1) int intervalSize, @NonNull Unit intervalUnit,
// @NonNull String friendlyName) {
// this.intervalSize = intervalSize;
// this.intervalUnit = intervalUnit;
// this.friendlyName = friendlyName;
// }
//
// public String getFriendlyName() {
// return friendlyName;
// }
//
// public @NonNull LocalDate getLastResetDate(LocalDate fromDate) {
// switch (intervalUnit) {
// case NULL:
// return LocalDate.ofEpochDay(0);
// case DAY:
// return calcLastResetDayForDay(fromDate);
// case WEEK:
// return calcLastResetDayForWeek(fromDate);
// case MONTH:
// return calcLastResetDayForMonth(fromDate);
// default:
// throw new UnsupportedOperationException(intervalUnit.toString());
// }
// }
//
// public @NonNull LocalDate getNextResetDate(LocalDate fromDate) {
// switch (intervalUnit) {
// case NULL:
// return LocalDate.ofEpochDay(0);
// case DAY:
// return calcLastResetDayForDay(fromDate).plusDays(intervalSize);
// case WEEK:
// return calcLastResetDayForWeek(fromDate).plusWeeks(intervalSize);
// case MONTH:
// return calcLastResetDayForMonth(fromDate).plusMonths(intervalSize);
// default:
// throw new UnsupportedOperationException(intervalUnit.toString());
// }
// }
//
// public boolean isResetDay(LocalDate day) {
// LocalDate resetDay;
// switch(intervalUnit) {
// case NULL:
// return false;
// case DAY:
// resetDay = calcLastResetDayForDay(day); break;
// case WEEK:
// resetDay = calcLastResetDayForWeek(day); break;
// case MONTH:
// resetDay = calcLastResetDayForMonth(day); break;
// default: throw new UnsupportedOperationException(intervalUnit.toString());
// }
//
// return resetDay.isEqual(day);
// }
//
// private LocalDate calcLastResetDayForDay(LocalDate fromDate) {
// int daysDelta = (fromDate.getDayOfYear() - 1) % intervalSize;
// return fromDate.minusDays(daysDelta);
// }
//
// private LocalDate calcLastResetDayForWeek(LocalDate fromDate) {
// // starting point is the first Monday of the year
// // FIXME fails with intervalSize != 1
// LocalDate startDate =
// fromDate.withDayOfYear(1).with(TemporalAdjusters.nextOrSame(DayOfWeek.MONDAY));
//
// long weekDelta = ChronoUnit.WEEKS.between(startDate, fromDate) % intervalSize;
//
// return fromDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).minusWeeks(weekDelta);
// }
//
// private LocalDate calcLastResetDayForMonth(LocalDate fromDate) {
// int monthsDelta = (fromDate.getMonthValue() - 1) % intervalSize;
// return fromDate.minusMonths(monthsDelta).withDayOfMonth(1);
// }
//
// public static FlexiReset loadFromPreferences(SharedPreferences preferences) {
// String key = Key.FLEXI_TIME_RESET_INTERVAL.getName();
// String defaultValue = FlexiReset.NONE.name();
// String string = preferences.getString(key, defaultValue);
// return valueOf(string);
// }
//
// }
| import android.content.Context;
import android.util.AttributeSet;
import androidx.preference.ListPreference;
import org.zephyrsoft.trackworktime.model.FlexiReset;
import java.util.ArrayList;
import java.util.List; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.options;
public class FlexiIntervalPreference extends ListPreference {
public FlexiIntervalPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initialize();
}
public FlexiIntervalPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
}
public FlexiIntervalPreference(Context context, AttributeSet attrs) {
super(context, attrs);
initialize();
}
public FlexiIntervalPreference(Context context) {
super(context);
initialize();
}
private void initialize() {
setDefaultSelection();
setEntries();
}
private void setDefaultSelection() { | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/FlexiReset.java
// public enum FlexiReset {
// NONE(1, Unit.NULL, "none"),
// DAILY(1, Unit.DAY, "daily"),
// WEEKLY(1, Unit.WEEK, "weekly"),
// MONTHLY(1, Unit.MONTH, "monthly"),
// QUARTERLY(3, Unit.MONTH, "quarterly"),
// HALF_YEARLY(6, Unit.MONTH, "half-yearly"),
// YEARLY(12, Unit.MONTH, "yearly");
//
// private final int intervalSize;
// private final Unit intervalUnit;
// private final String friendlyName;
//
// FlexiReset(@IntRange(from=1) int intervalSize, @NonNull Unit intervalUnit,
// @NonNull String friendlyName) {
// this.intervalSize = intervalSize;
// this.intervalUnit = intervalUnit;
// this.friendlyName = friendlyName;
// }
//
// public String getFriendlyName() {
// return friendlyName;
// }
//
// public @NonNull LocalDate getLastResetDate(LocalDate fromDate) {
// switch (intervalUnit) {
// case NULL:
// return LocalDate.ofEpochDay(0);
// case DAY:
// return calcLastResetDayForDay(fromDate);
// case WEEK:
// return calcLastResetDayForWeek(fromDate);
// case MONTH:
// return calcLastResetDayForMonth(fromDate);
// default:
// throw new UnsupportedOperationException(intervalUnit.toString());
// }
// }
//
// public @NonNull LocalDate getNextResetDate(LocalDate fromDate) {
// switch (intervalUnit) {
// case NULL:
// return LocalDate.ofEpochDay(0);
// case DAY:
// return calcLastResetDayForDay(fromDate).plusDays(intervalSize);
// case WEEK:
// return calcLastResetDayForWeek(fromDate).plusWeeks(intervalSize);
// case MONTH:
// return calcLastResetDayForMonth(fromDate).plusMonths(intervalSize);
// default:
// throw new UnsupportedOperationException(intervalUnit.toString());
// }
// }
//
// public boolean isResetDay(LocalDate day) {
// LocalDate resetDay;
// switch(intervalUnit) {
// case NULL:
// return false;
// case DAY:
// resetDay = calcLastResetDayForDay(day); break;
// case WEEK:
// resetDay = calcLastResetDayForWeek(day); break;
// case MONTH:
// resetDay = calcLastResetDayForMonth(day); break;
// default: throw new UnsupportedOperationException(intervalUnit.toString());
// }
//
// return resetDay.isEqual(day);
// }
//
// private LocalDate calcLastResetDayForDay(LocalDate fromDate) {
// int daysDelta = (fromDate.getDayOfYear() - 1) % intervalSize;
// return fromDate.minusDays(daysDelta);
// }
//
// private LocalDate calcLastResetDayForWeek(LocalDate fromDate) {
// // starting point is the first Monday of the year
// // FIXME fails with intervalSize != 1
// LocalDate startDate =
// fromDate.withDayOfYear(1).with(TemporalAdjusters.nextOrSame(DayOfWeek.MONDAY));
//
// long weekDelta = ChronoUnit.WEEKS.between(startDate, fromDate) % intervalSize;
//
// return fromDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).minusWeeks(weekDelta);
// }
//
// private LocalDate calcLastResetDayForMonth(LocalDate fromDate) {
// int monthsDelta = (fromDate.getMonthValue() - 1) % intervalSize;
// return fromDate.minusMonths(monthsDelta).withDayOfMonth(1);
// }
//
// public static FlexiReset loadFromPreferences(SharedPreferences preferences) {
// String key = Key.FLEXI_TIME_RESET_INTERVAL.getName();
// String defaultValue = FlexiReset.NONE.name();
// String string = preferences.getString(key, defaultValue);
// return valueOf(string);
// }
//
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/options/FlexiIntervalPreference.java
import android.content.Context;
import android.util.AttributeSet;
import androidx.preference.ListPreference;
import org.zephyrsoft.trackworktime.model.FlexiReset;
import java.util.ArrayList;
import java.util.List;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.options;
public class FlexiIntervalPreference extends ListPreference {
public FlexiIntervalPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initialize();
}
public FlexiIntervalPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
}
public FlexiIntervalPreference(Context context, AttributeSet attrs) {
super(context, attrs);
initialize();
}
public FlexiIntervalPreference(Context context) {
super(context);
initialize();
}
private void initialize() {
setDefaultSelection();
setEntries();
}
private void setDefaultSelection() { | setDefaultValue(FlexiReset.NONE.name()); |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/report/TimeSumsHolder.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/TimeSum.java
// public class TimeSum {
//
// /** can also be counted negative */
// private int hours = 0;
// /** always counted positive */
// private int minutes = 0;
//
// public void set(int minutes) {
// this.minutes = minutes;
// balance();
// }
//
// /**
// * Set time to specific values
// * @param hours positive or negative
// * @param minutes only positive. Does not spillover to hours.
// */
// public void set(int hours, int minutes) {
// if(minutes < 0 || minutes > 59) {
// throw new IllegalArgumentException("Minutes out of range: " + minutes);
// }
// if(hours < 0 && minutes > 0) {
// minutes = 60 - minutes;
// hours -= 1;
// }
// this.hours = hours;
// this.minutes = minutes;
// }
//
// /**
// * Add some hours and minutes. The minutes value doesn't have to be < 60, but both values have to be >= 0.
// */
// public void add(int hoursToAdd, int minutesToAdd) {
// if (hoursToAdd < 0 || minutesToAdd < 0) {
// throw new IllegalArgumentException("both values have to be >= 0");
// }
// hours += hoursToAdd;
// minutes += minutesToAdd;
// balance();
// }
//
// /**
// * Subtracts some hours and minutes. The minutes value doesn't have to be < 60, but both values have to be >= 0.
// */
// public void substract(int hoursToSubstract, int minutesToSubstract) {
// if (hoursToSubstract < 0 || minutesToSubstract < 0) {
// throw new IllegalArgumentException("both values have to be >= 0");
// }
// hours -= hoursToSubstract;
// minutes -= minutesToSubstract;
// balance();
// }
//
// /**
// * Add or substract the value of the given time sum.
// */
// public void addOrSubstract(TimeSum timeSum) {
// if (timeSum == null) {
// return;
// }
// hours += timeSum.hours;
// minutes += timeSum.minutes;
// balance();
// }
//
// private void balance() {
// while (minutes >= 60) {
// hours += 1;
// minutes -= 60;
// }
// while (minutes < 0) {
// hours -= 1;
// minutes += 60;
// }
// }
//
// @Override
// public String toString() {
// int hoursForDisplay = hours;
// int minutesForDisplay = minutes;
// boolean negative = false;
// if (hoursForDisplay < 0) {
// negative = true;
// if (minutesForDisplay != 0) {
// hoursForDisplay += 1;
// minutesForDisplay = 60 - minutesForDisplay;
// }
// }
// return (negative && hoursForDisplay == 0 ? "-" : "") + hoursForDisplay + ":"
// + DateTimeUtil.padToTwoDigits(minutesForDisplay);
// }
//
// /**
// * Get the time sum as accumulated value in minutes.
// */
// public int getAsMinutes() {
// return hours * 60 + minutes;
// }
//
// public void reset() {
// hours = 0;
// minutes = 0;
// }
//
// }
| import androidx.annotation.NonNull;
import org.apache.commons.lang3.builder.CompareToBuilder;
import org.zephyrsoft.trackworktime.model.TimeSum; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.report;
/**
* Holds the data for reporting.
*/
public class TimeSumsHolder implements Comparable<TimeSumsHolder> {
private String month;
private String week;
private String day;
private String task; | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/TimeSum.java
// public class TimeSum {
//
// /** can also be counted negative */
// private int hours = 0;
// /** always counted positive */
// private int minutes = 0;
//
// public void set(int minutes) {
// this.minutes = minutes;
// balance();
// }
//
// /**
// * Set time to specific values
// * @param hours positive or negative
// * @param minutes only positive. Does not spillover to hours.
// */
// public void set(int hours, int minutes) {
// if(minutes < 0 || minutes > 59) {
// throw new IllegalArgumentException("Minutes out of range: " + minutes);
// }
// if(hours < 0 && minutes > 0) {
// minutes = 60 - minutes;
// hours -= 1;
// }
// this.hours = hours;
// this.minutes = minutes;
// }
//
// /**
// * Add some hours and minutes. The minutes value doesn't have to be < 60, but both values have to be >= 0.
// */
// public void add(int hoursToAdd, int minutesToAdd) {
// if (hoursToAdd < 0 || minutesToAdd < 0) {
// throw new IllegalArgumentException("both values have to be >= 0");
// }
// hours += hoursToAdd;
// minutes += minutesToAdd;
// balance();
// }
//
// /**
// * Subtracts some hours and minutes. The minutes value doesn't have to be < 60, but both values have to be >= 0.
// */
// public void substract(int hoursToSubstract, int minutesToSubstract) {
// if (hoursToSubstract < 0 || minutesToSubstract < 0) {
// throw new IllegalArgumentException("both values have to be >= 0");
// }
// hours -= hoursToSubstract;
// minutes -= minutesToSubstract;
// balance();
// }
//
// /**
// * Add or substract the value of the given time sum.
// */
// public void addOrSubstract(TimeSum timeSum) {
// if (timeSum == null) {
// return;
// }
// hours += timeSum.hours;
// minutes += timeSum.minutes;
// balance();
// }
//
// private void balance() {
// while (minutes >= 60) {
// hours += 1;
// minutes -= 60;
// }
// while (minutes < 0) {
// hours -= 1;
// minutes += 60;
// }
// }
//
// @Override
// public String toString() {
// int hoursForDisplay = hours;
// int minutesForDisplay = minutes;
// boolean negative = false;
// if (hoursForDisplay < 0) {
// negative = true;
// if (minutesForDisplay != 0) {
// hoursForDisplay += 1;
// minutesForDisplay = 60 - minutesForDisplay;
// }
// }
// return (negative && hoursForDisplay == 0 ? "-" : "") + hoursForDisplay + ":"
// + DateTimeUtil.padToTwoDigits(minutesForDisplay);
// }
//
// /**
// * Get the time sum as accumulated value in minutes.
// */
// public int getAsMinutes() {
// return hours * 60 + minutes;
// }
//
// public void reset() {
// hours = 0;
// minutes = 0;
// }
//
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/report/TimeSumsHolder.java
import androidx.annotation.NonNull;
import org.apache.commons.lang3.builder.CompareToBuilder;
import org.zephyrsoft.trackworktime.model.TimeSum;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.report;
/**
* Holds the data for reporting.
*/
public class TimeSumsHolder implements Comparable<TimeSumsHolder> {
private String month;
private String week;
private String day;
private String task; | private TimeSum spent; |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekIndexConverter.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
| import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.ChronoUnit;
import org.zephyrsoft.trackworktime.model.Week; | /*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
/**
* Converts week-index to {@link Week} and vice versa, where week-index is number of weeks after epoch,
* starting with 0.
*
* E.g. index of 0 means 1st week after epoch.
*/
public class WeekIndexConverter {
private static final LocalDate epochDate = LocalDate.ofEpochDay(0);
| // Path: app/src/main/java/org/zephyrsoft/trackworktime/model/Week.java
// public class Week extends Base implements Comparable<Week> {
// private final LocalDate startDay;
//
// public Week(LocalDate date) {
// // TODO consider locale
// startDay = date.with(DayOfWeek.MONDAY);
// }
//
// public Week(long epochDay) {
// startDay = LocalDate.ofEpochDay(epochDay);
// }
//
// public LocalDate getStart() {
// return startDay;
// }
//
// public LocalDate getEnd() {
// // TODO consider locale
// return startDay.with(DayOfWeek.SUNDAY);
// }
//
// public long toEpochDay() {
// return startDay.toEpochDay();
// }
//
// public Week plusWeeks(long weeksToAdd) {
// return new Week(startDay.plusWeeks(weeksToAdd));
// }
//
// public boolean isInWeek(LocalDate date) {
// return !date.isBefore(startDay) && !date.isAfter(getEnd());
// }
//
// @Override
// public int compareTo(Week another) {
// //return compare(getStart(), another.getStart(), compare(getId(), another.getId(), 0));
// return compare(getStart(), another.getStart(), 0);
// }
//
// /**
// * This is used e.g. by an ArrayAdapter in a ListView and it is also useful for debugging.
// *
// * @see Base#toString()
// */
// @Override
// public String toString() {
// return startDay.toString();
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/weektimes/WeekIndexConverter.java
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.ChronoUnit;
import org.zephyrsoft.trackworktime.model.Week;
/*
* This file is part of TrackWorkTime (TWT).
*
* TWT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* TWT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License 3.0 for more details.
*
* You should have received a copy of the GNU General Public License 3.0
* along with TWT. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zephyrsoft.trackworktime.weektimes;
/**
* Converts week-index to {@link Week} and vice versa, where week-index is number of weeks after epoch,
* starting with 0.
*
* E.g. index of 0 means 1st week after epoch.
*/
public class WeekIndexConverter {
private static final LocalDate epochDate = LocalDate.ofEpochDay(0);
| public static @NonNull Week getWeekForIndex(@IntRange(from=0) int weekIndex) { |
mathisdt/trackworktime | app/src/main/java/org/zephyrsoft/trackworktime/WorkTimeTrackerApplication.java | // Path: app/src/main/java/org/zephyrsoft/trackworktime/util/TinylogAndLogcatLogger.java
// public class TinylogAndLogcatLogger implements ACRALog {
// @Override
// public int v(String tag, String msg) {
// Logger.trace(msg);
// return Log.v(tag, msg);
// }
// @Override
// public int v(String tag, String msg, Throwable tr) {
// Logger.trace(tr, msg);
// return Log.v(tag, msg, tr);
// }
// @Override
// public int d(String tag, String msg) {
// Logger.debug(msg);
// return Log.d(tag, msg);
// }
// @Override
// public int d(String tag, String msg, Throwable tr) {
// Logger.debug(tr, msg);
// return Log.d(tag, msg, tr);
// }
// @Override
// public int i(String tag, String msg) {
// Logger.info(msg);
// return Log.i(tag, msg);
// }
// @Override
// public int i(String tag, String msg, Throwable tr) {
// Logger.info(tr, msg);
// return Log.i(tag, msg, tr);
// }
// @Override
// public int w(String tag, String msg) {
// Logger.warn(msg);
// return Log.w(tag, msg);
// }
// @Override
// public int w(String tag, String msg, Throwable tr) {
// Logger.warn(tr, msg);
// return Log.w(tag, msg, tr);
// }
// @Override
// public int w(String tag, Throwable tr) {
// Logger.warn(tr);
// return Log.w(tag, tr);
// }
// @Override
// public int e(String tag, String msg) {
// Logger.error(msg);
// return Log.e(tag, msg);
// }
// @Override
// public int e(String tag, String msg, Throwable tr) {
// Logger.error(tr, msg);
// return Log.e(tag, msg, tr);
// }
// @Override
// public String getStackTraceString(Throwable tr) {
// return Log.getStackTraceString(tr);
// }
// }
| import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE;
import static org.acra.ReportField.APP_VERSION_NAME;
import static org.acra.ReportField.BRAND;
import static org.acra.ReportField.CRASH_CONFIGURATION;
import static org.acra.ReportField.INSTALLATION_ID;
import static org.acra.ReportField.LOGCAT;
import static org.acra.ReportField.PACKAGE_NAME;
import static org.acra.ReportField.PHONE_MODEL;
import static org.acra.ReportField.PRODUCT;
import static org.acra.ReportField.REPORT_ID;
import static org.acra.ReportField.SHARED_PREFERENCES;
import static org.acra.ReportField.STACK_TRACE;
import static org.acra.ReportField.USER_APP_START_DATE;
import static org.acra.ReportField.USER_CRASH_DATE;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
import com.jakewharton.threetenabp.AndroidThreeTen;
import org.acra.ACRA;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.DialogConfigurationBuilder;
import org.acra.config.HttpSenderConfigurationBuilder;
import org.acra.data.StringFormat;
import org.acra.sender.HttpSender;
import org.pmw.tinylog.Logger;
import org.zephyrsoft.trackworktime.util.TinylogAndLogcatLogger;
import java.util.concurrent.TimeUnit; |
name = getString(R.string.serviceChannelName);
description = getString(R.string.serviceChannelDescription);
importance = NotificationManager.IMPORTANCE_LOW;
serviceNotificationChannel = new NotificationChannel(name, name, importance);
serviceNotificationChannel.setDescription(description);
notificationManager.createNotificationChannel(serviceNotificationChannel);
}
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
.withBuildConfigClass(BuildConfig.class)
.withReportFormat(StringFormat.JSON)
.withReportContent(ANDROID_VERSION, APP_VERSION_CODE, APP_VERSION_NAME,
BRAND, CRASH_CONFIGURATION, INSTALLATION_ID, LOGCAT,
PACKAGE_NAME, PHONE_MODEL, PRODUCT, REPORT_ID, SHARED_PREFERENCES,
STACK_TRACE, USER_APP_START_DATE, USER_CRASH_DATE)
.withEnabled(true);
builder.getPluginConfigurationBuilder(DialogConfigurationBuilder.class)
.withResTitle(R.string.acraTitle)
.withResText(R.string.acraText)
.withResCommentPrompt(R.string.acraCommentPrompt)
.withEnabled(true);
builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class)
.withHttpMethod(HttpSender.Method.POST)
.withUri("https://crashreport.zephyrsoft.org/")
.withEnabled(true);
ACRA.init(this, builder); | // Path: app/src/main/java/org/zephyrsoft/trackworktime/util/TinylogAndLogcatLogger.java
// public class TinylogAndLogcatLogger implements ACRALog {
// @Override
// public int v(String tag, String msg) {
// Logger.trace(msg);
// return Log.v(tag, msg);
// }
// @Override
// public int v(String tag, String msg, Throwable tr) {
// Logger.trace(tr, msg);
// return Log.v(tag, msg, tr);
// }
// @Override
// public int d(String tag, String msg) {
// Logger.debug(msg);
// return Log.d(tag, msg);
// }
// @Override
// public int d(String tag, String msg, Throwable tr) {
// Logger.debug(tr, msg);
// return Log.d(tag, msg, tr);
// }
// @Override
// public int i(String tag, String msg) {
// Logger.info(msg);
// return Log.i(tag, msg);
// }
// @Override
// public int i(String tag, String msg, Throwable tr) {
// Logger.info(tr, msg);
// return Log.i(tag, msg, tr);
// }
// @Override
// public int w(String tag, String msg) {
// Logger.warn(msg);
// return Log.w(tag, msg);
// }
// @Override
// public int w(String tag, String msg, Throwable tr) {
// Logger.warn(tr, msg);
// return Log.w(tag, msg, tr);
// }
// @Override
// public int w(String tag, Throwable tr) {
// Logger.warn(tr);
// return Log.w(tag, tr);
// }
// @Override
// public int e(String tag, String msg) {
// Logger.error(msg);
// return Log.e(tag, msg);
// }
// @Override
// public int e(String tag, String msg, Throwable tr) {
// Logger.error(tr, msg);
// return Log.e(tag, msg, tr);
// }
// @Override
// public String getStackTraceString(Throwable tr) {
// return Log.getStackTraceString(tr);
// }
// }
// Path: app/src/main/java/org/zephyrsoft/trackworktime/WorkTimeTrackerApplication.java
import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE;
import static org.acra.ReportField.APP_VERSION_NAME;
import static org.acra.ReportField.BRAND;
import static org.acra.ReportField.CRASH_CONFIGURATION;
import static org.acra.ReportField.INSTALLATION_ID;
import static org.acra.ReportField.LOGCAT;
import static org.acra.ReportField.PACKAGE_NAME;
import static org.acra.ReportField.PHONE_MODEL;
import static org.acra.ReportField.PRODUCT;
import static org.acra.ReportField.REPORT_ID;
import static org.acra.ReportField.SHARED_PREFERENCES;
import static org.acra.ReportField.STACK_TRACE;
import static org.acra.ReportField.USER_APP_START_DATE;
import static org.acra.ReportField.USER_CRASH_DATE;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
import com.jakewharton.threetenabp.AndroidThreeTen;
import org.acra.ACRA;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.DialogConfigurationBuilder;
import org.acra.config.HttpSenderConfigurationBuilder;
import org.acra.data.StringFormat;
import org.acra.sender.HttpSender;
import org.pmw.tinylog.Logger;
import org.zephyrsoft.trackworktime.util.TinylogAndLogcatLogger;
import java.util.concurrent.TimeUnit;
name = getString(R.string.serviceChannelName);
description = getString(R.string.serviceChannelDescription);
importance = NotificationManager.IMPORTANCE_LOW;
serviceNotificationChannel = new NotificationChannel(name, name, importance);
serviceNotificationChannel.setDescription(description);
notificationManager.createNotificationChannel(serviceNotificationChannel);
}
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
.withBuildConfigClass(BuildConfig.class)
.withReportFormat(StringFormat.JSON)
.withReportContent(ANDROID_VERSION, APP_VERSION_CODE, APP_VERSION_NAME,
BRAND, CRASH_CONFIGURATION, INSTALLATION_ID, LOGCAT,
PACKAGE_NAME, PHONE_MODEL, PRODUCT, REPORT_ID, SHARED_PREFERENCES,
STACK_TRACE, USER_APP_START_DATE, USER_CRASH_DATE)
.withEnabled(true);
builder.getPluginConfigurationBuilder(DialogConfigurationBuilder.class)
.withResTitle(R.string.acraTitle)
.withResText(R.string.acraText)
.withResCommentPrompt(R.string.acraCommentPrompt)
.withEnabled(true);
builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class)
.withHttpMethod(HttpSender.Method.POST)
.withUri("https://crashreport.zephyrsoft.org/")
.withEnabled(true);
ACRA.init(this, builder); | ACRA.log = new TinylogAndLogcatLogger(); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/Order.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderStatus.java
// public enum OrderStatus {
//
// ACTIVATED, PLACED
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class Order extends AggregateRoot<OrderId> {
private OrderStatus status;
public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
assertHasNotBeenPlaced();
assertMoreThanZeroOrderLines(orderLines); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderStatus.java
// public enum OrderStatus {
//
// ACTIVATED, PLACED
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/Order.java
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class Order extends AggregateRoot<OrderId> {
private OrderStatus status;
public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
assertHasNotBeenPlaced();
assertMoreThanZeroOrderLines(orderLines); | applyChange(new OrderPlacedEvent(orderId, nextVersion(), now(), toCustomerInformation(customerInformation), |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/Order.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderStatus.java
// public enum OrderStatus {
//
// ACTIVATED, PLACED
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class Order extends AggregateRoot<OrderId> {
private OrderStatus status;
public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
assertHasNotBeenPlaced();
assertMoreThanZeroOrderLines(orderLines);
applyChange(new OrderPlacedEvent(orderId, nextVersion(), now(), toCustomerInformation(customerInformation),
toOrderLines(orderLines), totalAmount));
}
public void activate() {
if (orderIsPlaced()) { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderStatus.java
// public enum OrderStatus {
//
// ACTIVATED, PLACED
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/Order.java
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class Order extends AggregateRoot<OrderId> {
private OrderStatus status;
public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
assertHasNotBeenPlaced();
assertMoreThanZeroOrderLines(orderLines);
applyChange(new OrderPlacedEvent(orderId, nextVersion(), now(), toCustomerInformation(customerInformation),
toOrderLines(orderLines), totalAmount));
}
public void activate() {
if (orderIsPlaced()) { | applyChange(new OrderActivatedEvent(id(), nextVersion(), now())); |
citerus/bookstore-cqrs-example | cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
| import se.citerus.cqrs.bookstore.GenericId; | package se.citerus.cqrs.bookstore.domain;
public interface Repository {
<AR extends AggregateRoot> void save(AR aggregateRoot);
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
import se.citerus.cqrs.bookstore.GenericId;
package se.citerus.cqrs.bookstore.domain;
public interface Repository {
<AR extends AggregateRoot> void save(AR aggregateRoot);
| <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType); |
citerus/bookstore-cqrs-example | cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
| import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import java.util.List; | package se.citerus.cqrs.bookstore.event;
public interface DomainEventStore {
List<DomainEvent> loadEvents(GenericId id);
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import java.util.List;
package se.citerus.cqrs.bookstore.event;
public interface DomainEventStore {
List<DomainEvent> loadEvents(GenericId id);
| void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract(); | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract(); | PublisherContractId publisherContractId = PublisherContractId.randomId(); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
double feePercentage = 5.0;
contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT);
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
double feePercentage = 5.0;
contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT);
| PublisherContractRegisteredEvent event = getOnlyElement(filter(contract.getUncommittedEvents(), |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
double feePercentage = 5.0;
contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT);
PublisherContractRegisteredEvent event = getOnlyElement(filter(contract.getUncommittedEvents(),
PublisherContractRegisteredEvent.class));
assertThat(event.feePercentage, is(5.0));
assertThat(event.publisherName, is("Addison Wesley"));
}
@Test(expected = IllegalStateException.class)
public void testCannotRegisterTwice() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
}
@Test
public void testRegisterPurchase() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 10.0, 10000);
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
double feePercentage = 5.0;
contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT);
PublisherContractRegisteredEvent event = getOnlyElement(filter(contract.getUncommittedEvents(),
PublisherContractRegisteredEvent.class));
assertThat(event.feePercentage, is(5.0));
assertThat(event.publisherName, is("Addison Wesley"));
}
@Test(expected = IllegalStateException.class)
public void testCannotRegisterTwice() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
}
@Test
public void testRegisterPurchase() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 10.0, 10000);
| contract.registerPurchase(ProductId.randomId(), 60000L, 1); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
double feePercentage = 5.0;
contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT);
PublisherContractRegisteredEvent event = getOnlyElement(filter(contract.getUncommittedEvents(),
PublisherContractRegisteredEvent.class));
assertThat(event.feePercentage, is(5.0));
assertThat(event.publisherName, is("Addison Wesley"));
}
@Test(expected = IllegalStateException.class)
public void testCannotRegisterTwice() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
}
@Test
public void testRegisterPurchase() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 10.0, 10000);
contract.registerPurchase(ProductId.randomId(), 60000L, 1);
contract.registerPurchase(ProductId.randomId(), 60000L, 1);
contract.registerPurchase(ProductId.randomId(), 60000L, 1);
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContractTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import java.util.Iterator;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContractTest {
private static final long LIMIT = 100_000;
@Test
public void testRegisterPublisher() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
double feePercentage = 5.0;
contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT);
PublisherContractRegisteredEvent event = getOnlyElement(filter(contract.getUncommittedEvents(),
PublisherContractRegisteredEvent.class));
assertThat(event.feePercentage, is(5.0));
assertThat(event.publisherName, is("Addison Wesley"));
}
@Test(expected = IllegalStateException.class)
public void testCannotRegisterTwice() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT);
}
@Test
public void testRegisterPurchase() {
PublisherContract contract = new PublisherContract();
PublisherContractId publisherContractId = PublisherContractId.randomId();
contract.register(publisherContractId, "Addison Wesley", 10.0, 10000);
contract.registerPurchase(ProductId.randomId(), 60000L, 1);
contract.registerPurchase(ProductId.randomId(), 60000L, 1);
contract.registerPurchase(ProductId.randomId(), 60000L, 1);
| Iterator<PurchaseRegisteredEvent> purchases = filter(contract.getUncommittedEvents(), |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.ordercontext.api;
public class PlaceOrderRequest extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.ordercontext.api;
public class PlaceOrderRequest extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderStatus.java
// public enum OrderStatus {
//
// ACTIVATED, PLACED
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/Projection.java
// public class Projection {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
| import com.fasterxml.jackson.annotation.JsonProperty;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus;
import se.citerus.cqrs.bookstore.ordercontext.query.Projection;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderProjection extends Projection {
private final OrderId orderId;
private final long orderPlacedTimestamp;
private final long orderAmount;
private final String customerName;
private final List<OrderLineProjection> orderLines; | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderStatus.java
// public enum OrderStatus {
//
// ACTIVATED, PLACED
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/Projection.java
// public class Projection {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
import com.fasterxml.jackson.annotation.JsonProperty;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus;
import se.citerus.cqrs.bookstore.ordercontext.query.Projection;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderProjection extends Projection {
private final OrderId orderId;
private final long orderPlacedTimestamp;
private final long orderAmount;
private final String customerName;
private final List<OrderLineProjection> orderLines; | private OrderStatus status; |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder() | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder() | .addResource(new CartResource(productCatalogClient, new InMemoryCartRepository())) |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
| // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
| ProductDto productDto = new ProductDto(); |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price; | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price; | productDto.book = new BookDto(); |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price;
productDto.book = new BookDto();
productDto.book.title = title;
when(productCatalogClient.getProduct(productId)).thenReturn(productDto); | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price;
productDto.book = new BookDto();
productDto.book.title = title;
when(productCatalogClient.getProduct(productId)).thenReturn(productDto); | CartDto cart = addItemToCart(cartId, addProductItemRequest(productId)).readEntity(CartDto.class); |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price;
productDto.book = new BookDto();
productDto.book.title = title;
when(productCatalogClient.getProduct(productId)).thenReturn(productDto);
CartDto cart = addItemToCart(cartId, addProductItemRequest(productId)).readEntity(CartDto.class);
| // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.shopping.resource;
public class CartResourceTest {
private static ProductCatalogClient productCatalogClient = mock(ProductCatalogClient.class);
private static final String CART_RESOURCE = "/carts";
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new CartResource(productCatalogClient, new InMemoryCartRepository()))
.build();
@After
public void tearDown() throws Exception {
reset(productCatalogClient);
}
@Test
public void getItemsFromSession() {
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price;
productDto.book = new BookDto();
productDto.book.title = title;
when(productCatalogClient.getProduct(productId)).thenReturn(productDto);
CartDto cart = addItemToCart(cartId, addProductItemRequest(productId)).readEntity(CartDto.class);
| LineItemDto expectedLineItem = new LineItemDto(); |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price;
productDto.book = new BookDto();
productDto.book.title = title;
when(productCatalogClient.getProduct(productId)).thenReturn(productDto);
CartDto cart = addItemToCart(cartId, addProductItemRequest(productId)).readEntity(CartDto.class);
LineItemDto expectedLineItem = new LineItemDto();
expectedLineItem.productId = productId;
expectedLineItem.title = title;
expectedLineItem.price = price;
expectedLineItem.quantity = 1;
expectedLineItem.totalPrice = price;
assertThat(cart.lineItems, hasSize(1));
assertThat(cart.lineItems, hasItems(expectedLineItem));
}
@Test
public void cannotAddNonExistingItem() {
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
| // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
String title = "test title";
long price = 200L;
String productId = UUID.randomUUID().toString();
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
ProductDto productDto = new ProductDto();
productDto.price = price;
productDto.book = new BookDto();
productDto.book.title = title;
when(productCatalogClient.getProduct(productId)).thenReturn(productDto);
CartDto cart = addItemToCart(cartId, addProductItemRequest(productId)).readEntity(CartDto.class);
LineItemDto expectedLineItem = new LineItemDto();
expectedLineItem.productId = productId;
expectedLineItem.title = title;
expectedLineItem.price = price;
expectedLineItem.quantity = 1;
expectedLineItem.totalPrice = price;
assertThat(cart.lineItems, hasSize(1));
assertThat(cart.lineItems, hasItems(expectedLineItem));
}
@Test
public void cannotAddNonExistingItem() {
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
| AddItemRequest addItemRequest = addProductItemRequest(UUID.randomUUID().toString()); |
citerus/bookstore-cqrs-example | shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
CartDto cart = resources.client()
.target(CART_RESOURCE + "/" + cartId)
.request(APPLICATION_JSON_TYPE)
.get(CartDto.class);
assertThat(cart.cartId, is(cartId));
assertThat(cart.totalPrice, is(0L));
}
@Test
public void shouldClearCart() {
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
resources.client().target(CART_RESOURCE + "/" + cartId).request().delete();
createCartWithId(cartId);
}
private Response addItemToCart(String cartId, AddItemRequest addItemRequest) {
return resources.client()
.target(CART_RESOURCE + "/" + cartId + "/items")
.request()
.post(Entity.json(addItemRequest), Response.class);
}
private void createCartWithId(String cartId) { | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
// public class AddItemRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDto.java
// public class CartDto extends TransportObject {
//
// public String cartId;
//
// public long totalPrice;
//
// public int totalQuantity;
//
// public List<LineItemDto> lineItems;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
// public class CreateCartRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/LineItemDto.java
// public class LineItemDto extends TransportObject {
//
// public String productId;
//
// public String title;
//
// public long price;
//
// public int quantity;
//
// public long totalPrice;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/BookDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class BookDto extends TransportObject {
//
// public String title;
//
// public String isbn;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductDto.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ProductDto extends TransportObject {
//
// public BookDto book;
//
// public long price;
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
// Path: shopping-context/src/test/java/se/citerus/cqrs/bookstore/shopping/resource/CartResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.shopping.api.AddItemRequest;
import se.citerus.cqrs.bookstore.shopping.api.CartDto;
import se.citerus.cqrs.bookstore.shopping.api.CreateCartRequest;
import se.citerus.cqrs.bookstore.shopping.api.LineItemDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.BookDto;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductDto;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.UUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
CartDto cart = resources.client()
.target(CART_RESOURCE + "/" + cartId)
.request(APPLICATION_JSON_TYPE)
.get(CartDto.class);
assertThat(cart.cartId, is(cartId));
assertThat(cart.totalPrice, is(0L));
}
@Test
public void shouldClearCart() {
String cartId = UUID.randomUUID().toString();
createCartWithId(cartId);
resources.client().target(CART_RESOURCE + "/" + cartId).request().delete();
createCartWithId(cartId);
}
private Response addItemToCart(String cartId, AddItemRequest addItemRequest) {
return resources.client()
.target(CART_RESOURCE + "/" + cartId + "/items")
.request()
.post(Entity.json(addItemRequest), Response.class);
}
private void createCartWithId(String cartId) { | CreateCartRequest createCart = new CreateCartRequest(); |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaCommandBus.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
| import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaCommandBus implements CommandBus {
private final EventBus commandBus;
private GuavaCommandBus(EventBus commandBus) {
this.commandBus = commandBus;
}
public static CommandBus asyncGuavaCommandBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
return new GuavaCommandBus(new AsyncEventBus("commandbus", executorService));
}
public static CommandBus syncGuavaCommandBus() {
return new GuavaCommandBus(new EventBus("commandbus"));
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaCommandBus.java
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaCommandBus implements CommandBus {
private final EventBus commandBus;
private GuavaCommandBus(EventBus commandBus) {
this.commandBus = commandBus;
}
public static CommandBus asyncGuavaCommandBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
return new GuavaCommandBus(new AsyncEventBus("commandbus", executorService));
}
public static CommandBus syncGuavaCommandBus() {
return new GuavaCommandBus(new EventBus("commandbus"));
}
@Override | public <T extends CommandHandler> T register(T handler) { |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaCommandBus.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
| import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaCommandBus implements CommandBus {
private final EventBus commandBus;
private GuavaCommandBus(EventBus commandBus) {
this.commandBus = commandBus;
}
public static CommandBus asyncGuavaCommandBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
return new GuavaCommandBus(new AsyncEventBus("commandbus", executorService));
}
public static CommandBus syncGuavaCommandBus() {
return new GuavaCommandBus(new EventBus("commandbus"));
}
@Override
public <T extends CommandHandler> T register(T handler) {
commandBus.register(handler);
return handler;
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaCommandBus.java
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaCommandBus implements CommandBus {
private final EventBus commandBus;
private GuavaCommandBus(EventBus commandBus) {
this.commandBus = commandBus;
}
public static CommandBus asyncGuavaCommandBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
return new GuavaCommandBus(new AsyncEventBus("commandbus", executorService));
}
public static CommandBus syncGuavaCommandBus() {
return new GuavaCommandBus(new EventBus("commandbus"));
}
@Override
public <T extends CommandHandler> T register(T handler) {
commandBus.register(handler);
return handler;
}
@Override | public void dispatch(Command command) { |
citerus/bookstore-cqrs-example | order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import com.fasterxml.jackson.annotation.JsonProperty;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import java.util.Collections;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.event;
public class OrderPlacedEvent extends DomainEvent<OrderId> {
public final CustomerInformation customerInformation; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
import com.fasterxml.jackson.annotation.JsonProperty;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import java.util.Collections;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.event;
public class OrderPlacedEvent extends DomainEvent<OrderId> {
public final CustomerInformation customerInformation; | public final List<OrderLine> orderLines; |
citerus/bookstore-cqrs-example | product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/application/TestProductDataImporter.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
| import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import org.junit.Ignore;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.Resources.getResource; | package se.citerus.cqrs.bookstore.productcatalog.application;
@Ignore
public class TestProductDataImporter {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final String SERVER_RESOURCE = "http://localhost:8090/products";
private static final String DEFAULT_PATH = "test-products.json";
public static void main(String[] args) {
try {
TestHttpClient productClient = new TestHttpClient(SERVER_RESOURCE).init();
// Add products
String productJson = Resources.toString(getResource(DEFAULT_PATH), UTF_8); | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
// Path: product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/application/TestProductDataImporter.java
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import org.junit.Ignore;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.Resources.getResource;
package se.citerus.cqrs.bookstore.productcatalog.application;
@Ignore
public class TestProductDataImporter {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final String SERVER_RESOURCE = "http://localhost:8090/products";
private static final String DEFAULT_PATH = "test-products.json";
public static void main(String[] args) {
try {
TestHttpClient productClient = new TestHttpClient(SERVER_RESOURCE).init();
// Add products
String productJson = Resources.toString(getResource(DEFAULT_PATH), UTF_8); | TypeReference<List<ProductDto>> listOfProductRequests = new TypeReference<List<ProductDto>>() { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.*; | package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepository implements OrderProjectionRepository {
private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator(); | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.*;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepository implements OrderProjectionRepository {
private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator(); | private final Map<OrderId, OrderProjection> orders = new HashMap<>(); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.*; | package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepository implements OrderProjectionRepository {
private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator(); | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.*;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepository implements OrderProjectionRepository {
private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator(); | private final Map<OrderId, OrderProjection> orders = new HashMap<>(); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
/**
* Listens to order events and stores projections of orders and their status as read models in the
* {@link OrderProjectionRepository}. Supports retrieving lists of orders as well as individual orders by id.
*/
public class OrderListDenormalizer implements DomainEventListener {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final OrderProjectionRepository repository;
public OrderListDenormalizer(OrderProjectionRepository repository) {
this.repository = repository;
}
@Subscribe | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
/**
* Listens to order events and stores projections of orders and their status as read models in the
* {@link OrderProjectionRepository}. Supports retrieving lists of orders as well as individual orders by id.
*/
public class OrderListDenormalizer implements DomainEventListener {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final OrderProjectionRepository repository;
public OrderListDenormalizer(OrderProjectionRepository repository) {
this.repository = repository;
}
@Subscribe | public void handleEvent(OrderPlacedEvent event) { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
/**
* Listens to order events and stores projections of orders and their status as read models in the
* {@link OrderProjectionRepository}. Supports retrieving lists of orders as well as individual orders by id.
*/
public class OrderListDenormalizer implements DomainEventListener {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final OrderProjectionRepository repository;
public OrderListDenormalizer(OrderProjectionRepository repository) {
this.repository = repository;
}
@Subscribe
public void handleEvent(OrderPlacedEvent event) {
logger.info("Received: " + event.toString());
List<OrderLineProjection> orderLines = new LinkedList<>(); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
/**
* Listens to order events and stores projections of orders and their status as read models in the
* {@link OrderProjectionRepository}. Supports retrieving lists of orders as well as individual orders by id.
*/
public class OrderListDenormalizer implements DomainEventListener {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final OrderProjectionRepository repository;
public OrderListDenormalizer(OrderProjectionRepository repository) {
this.repository = repository;
}
@Subscribe
public void handleEvent(OrderPlacedEvent event) {
logger.info("Received: " + event.toString());
List<OrderLineProjection> orderLines = new LinkedList<>(); | for (OrderLine orderLine : event.orderLines) { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
/**
* Listens to order events and stores projections of orders and their status as read models in the
* {@link OrderProjectionRepository}. Supports retrieving lists of orders as well as individual orders by id.
*/
public class OrderListDenormalizer implements DomainEventListener {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final OrderProjectionRepository repository;
public OrderListDenormalizer(OrderProjectionRepository repository) {
this.repository = repository;
}
@Subscribe
public void handleEvent(OrderPlacedEvent event) {
logger.info("Received: " + event.toString());
List<OrderLineProjection> orderLines = new LinkedList<>();
for (OrderLine orderLine : event.orderLines) {
OrderLineProjection line = new OrderLineProjection();
line.productId = orderLine.productId;
line.quantity = orderLine.quantity;
line.title = orderLine.title;
line.unitPrice = orderLine.unitPrice;
orderLines.add(line);
}
OrderProjection orderProjection = new OrderProjection(event.aggregateId, event.timestamp,
event.customerInformation.customerName, event.orderAmount, orderLines, PLACED);
repository.save(orderProjection);
}
@Subscribe | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
/**
* Listens to order events and stores projections of orders and their status as read models in the
* {@link OrderProjectionRepository}. Supports retrieving lists of orders as well as individual orders by id.
*/
public class OrderListDenormalizer implements DomainEventListener {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final OrderProjectionRepository repository;
public OrderListDenormalizer(OrderProjectionRepository repository) {
this.repository = repository;
}
@Subscribe
public void handleEvent(OrderPlacedEvent event) {
logger.info("Received: " + event.toString());
List<OrderLineProjection> orderLines = new LinkedList<>();
for (OrderLine orderLine : event.orderLines) {
OrderLineProjection line = new OrderLineProjection();
line.productId = orderLine.productId;
line.quantity = orderLine.quantity;
line.title = orderLine.title;
line.unitPrice = orderLine.unitPrice;
orderLines.add(line);
}
OrderProjection orderProjection = new OrderProjection(event.aggregateId, event.timestamp,
event.customerInformation.customerName, event.orderAmount, orderLines, PLACED);
repository.save(orderProjection);
}
@Subscribe | public void handleEvent(OrderActivatedEvent event) { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | List<OrderLineProjection> orderLines = new LinkedList<>();
for (OrderLine orderLine : event.orderLines) {
OrderLineProjection line = new OrderLineProjection();
line.productId = orderLine.productId;
line.quantity = orderLine.quantity;
line.title = orderLine.title;
line.unitPrice = orderLine.unitPrice;
orderLines.add(line);
}
OrderProjection orderProjection = new OrderProjection(event.aggregateId, event.timestamp,
event.customerInformation.customerName, event.orderAmount, orderLines, PLACED);
repository.save(orderProjection);
}
@Subscribe
public void handleEvent(OrderActivatedEvent event) {
logger.info("Received: " + event.toString());
OrderProjection orderProjection = repository.getById(event.aggregateId);
orderProjection.setStatus(ACTIVATED);
}
public List<OrderProjection> getOrders() {
return repository.listOrdersByTimestamp();
}
@Override
public boolean supportsReplay() {
return true;
}
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizer.java
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.LinkedList;
import java.util.List;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
List<OrderLineProjection> orderLines = new LinkedList<>();
for (OrderLine orderLine : event.orderLines) {
OrderLineProjection line = new OrderLineProjection();
line.productId = orderLine.productId;
line.quantity = orderLine.quantity;
line.title = orderLine.title;
line.unitPrice = orderLine.unitPrice;
orderLines.add(line);
}
OrderProjection orderProjection = new OrderProjection(event.aggregateId, event.timestamp,
event.customerInformation.customerName, event.orderAmount, orderLines, PLACED);
repository.save(orderProjection);
}
@Subscribe
public void handleEvent(OrderActivatedEvent event) {
logger.info("Received: " + event.toString());
OrderProjection orderProjection = repository.getById(event.aggregateId);
orderProjection.setStatus(ACTIVATED);
}
public List<OrderProjection> getOrders() {
return repository.listOrdersByTimestamp();
}
@Override
public boolean supportsReplay() {
return true;
}
| public OrderProjection get(OrderId orderId) { |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.productcatalog.api;
public class BookDto extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.productcatalog.api;
public class BookDto extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/task/ReplayEventsTask.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import com.google.common.collect.ImmutableMultimap;
import io.dropwizard.servlets.tasks.Task;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.PrintWriter; | package se.citerus.cqrs.bookstore.ordercontext.application.task;
public class ReplayEventsTask extends Task {
private final DomainEventStore domainEventStore; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/task/ReplayEventsTask.java
import com.google.common.collect.ImmutableMultimap;
import io.dropwizard.servlets.tasks.Task;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.PrintWriter;
package se.citerus.cqrs.bookstore.ordercontext.application.task;
public class ReplayEventsTask extends Task {
private final DomainEventStore domainEventStore; | private final DomainEventBus domainEventBus; |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaDomainEventBus.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
| import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaDomainEventBus implements DomainEventBus {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final EventBus eventBus;
private final EventBus replayBus;
public GuavaDomainEventBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
eventBus = new AsyncEventBus("eventbus", executorService);
replayBus = new AsyncEventBus("replaybus", executorService);
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaDomainEventBus.java
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaDomainEventBus implements DomainEventBus {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final EventBus eventBus;
private final EventBus replayBus;
public GuavaDomainEventBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
eventBus = new AsyncEventBus("eventbus", executorService);
replayBus = new AsyncEventBus("replaybus", executorService);
}
@Override | public <T extends DomainEventListener> T register(T listener) { |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaDomainEventBus.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
| import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaDomainEventBus implements DomainEventBus {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final EventBus eventBus;
private final EventBus replayBus;
public GuavaDomainEventBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
eventBus = new AsyncEventBus("eventbus", executorService);
replayBus = new AsyncEventBus("replaybus", executorService);
}
@Override
public <T extends DomainEventListener> T register(T listener) {
if (listener.supportsReplay()) {
replayBus.register(listener);
}
eventBus.register(listener);
return listener;
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaDomainEventBus.java
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class GuavaDomainEventBus implements DomainEventBus {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final EventBus eventBus;
private final EventBus replayBus;
public GuavaDomainEventBus() {
ExecutorService executorService = Executors.newFixedThreadPool(1);
eventBus = new AsyncEventBus("eventbus", executorService);
replayBus = new AsyncEventBus("replaybus", executorService);
}
@Override
public <T extends DomainEventListener> T register(T listener) {
if (listener.supportsReplay()) {
replayBus.register(listener);
}
eventBus.register(listener);
return listener;
}
@Override | public void publish(List<DomainEvent> events) { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
| import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
| private final QueryService queryService; |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
| import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
private final QueryService queryService; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
private final QueryService queryService; | private final DomainEventStore eventStore; |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
| import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
private final QueryService queryService;
private final DomainEventStore eventStore;
public QueryResource(QueryService queryService, DomainEventStore eventStore) {
this.queryService = queryService;
this.eventStore = eventStore;
}
@GET
@Path("events")
public List<Object[]> getAllEvents() { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
private final QueryService queryService;
private final DomainEventStore eventStore;
public QueryResource(QueryService queryService, DomainEventStore eventStore) {
this.queryService = queryService;
this.eventStore = eventStore;
}
@GET
@Path("events")
public List<Object[]> getAllEvents() { | List<DomainEvent> allEvents = eventStore.getAllEvents(); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
| import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
private final QueryService queryService;
private final DomainEventStore eventStore;
public QueryResource(QueryService queryService, DomainEventStore eventStore) {
this.queryService = queryService;
this.eventStore = eventStore;
}
@GET
@Path("events")
public List<Object[]> getAllEvents() {
List<DomainEvent> allEvents = eventStore.getAllEvents();
List<Object[]> eventsToReturn = new LinkedList<>();
for (DomainEvent event : allEvents) {
eventsToReturn.add(new Object[]{event.getClass().getSimpleName(), event});
}
return eventsToReturn;
}
@GET
@Path("orders") | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/QueryResource.java
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("query")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class QueryResource {
private final QueryService queryService;
private final DomainEventStore eventStore;
public QueryResource(QueryService queryService, DomainEventStore eventStore) {
this.queryService = queryService;
this.eventStore = eventStore;
}
@GET
@Path("events")
public List<Object[]> getAllEvents() {
List<DomainEvent> allEvents = eventStore.getAllEvents();
List<Object[]> eventsToReturn = new LinkedList<>();
for (DomainEvent event : allEvents) {
eventsToReturn.add(new Object[]{event.getClass().getSimpleName(), event});
}
return eventsToReturn;
}
@GET
@Path("orders") | public Collection<OrderProjection> getOrders() { |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.shopping.api;
public class AddItemRequest extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/AddItemRequest.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.shopping.api;
public class AddItemRequest extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order(); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order(); | OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order(); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order(); | OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order(); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order(); | OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); | order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L); | List<DomainEvent> uncommittedEvents = order.getUncommittedEvents(); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L);
List<DomainEvent> uncommittedEvents = order.getUncommittedEvents();
assertThat(uncommittedEvents.size(), is(1));
assertThat(order.version(), is(1)); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L);
List<DomainEvent> uncommittedEvents = order.getUncommittedEvents();
assertThat(uncommittedEvents.size(), is(1));
assertThat(order.version(), is(1)); | assertThat(getOnlyElement(uncommittedEvents), instanceOf(OrderPlacedEvent.class)); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId; | package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L);
List<DomainEvent> uncommittedEvents = order.getUncommittedEvents();
assertThat(uncommittedEvents.size(), is(1));
assertThat(order.version(), is(1));
assertThat(getOnlyElement(uncommittedEvents), instanceOf(OrderPlacedEvent.class));
}
@Test
public void activatingAnOrder() {
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
Order order = new Order();
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L);
int nEvents = order.getUncommittedEvents().size();
order.activate();
List<DomainEvent> uncommittedEvents = order.getUncommittedEvents();
assertThat(uncommittedEvents.size(), is(nEvents +1));
assertThat(order.version(), is(2)); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
//
// public BookId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static BookId randomId() {
// return new BookId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;
public class OrderTest {
private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");
@Test
public void placingAnOrder() {
Order order = new Order();
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L);
List<DomainEvent> uncommittedEvents = order.getUncommittedEvents();
assertThat(uncommittedEvents.size(), is(1));
assertThat(order.version(), is(1));
assertThat(getOnlyElement(uncommittedEvents), instanceOf(OrderPlacedEvent.class));
}
@Test
public void activatingAnOrder() {
OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
Order order = new Order();
order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L);
int nEvents = order.getUncommittedEvents().size();
order.activate();
List<DomainEvent> uncommittedEvents = order.getUncommittedEvents();
assertThat(uncommittedEvents.size(), is(nEvents +1));
assertThat(order.version(), is(2)); | assertThat(getLast(uncommittedEvents), instanceOf(OrderActivatedEvent.class)); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.ordercontext.api;
public class CartDto {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.ordercontext.api;
public class CartDto {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.productcatalog.api;
public class ProductDto extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.productcatalog.api;
public class ProductDto extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregator.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import org.joda.time.LocalDate;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Map;
import java.util.TreeMap; | package se.citerus.cqrs.bookstore.ordercontext.query.sales;
/**
* Simple in memory aggregator counting placed orders per day based on order timestamp.
*/
public class OrdersPerDayAggregator implements DomainEventListener {
private final TreeMap<LocalDate, Integer> orders = new TreeMap<>();
@Subscribe | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventListener.java
// public interface DomainEventListener {
//
// boolean supportsReplay();
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregator.java
import com.google.common.eventbus.Subscribe;
import org.joda.time.LocalDate;
import se.citerus.cqrs.bookstore.event.DomainEventListener;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Map;
import java.util.TreeMap;
package se.citerus.cqrs.bookstore.ordercontext.query.sales;
/**
* Simple in memory aggregator counting placed orders per day based on order timestamp.
*/
public class OrdersPerDayAggregator implements DomainEventListener {
private final TreeMap<LocalDate, Integer> orders = new TreeMap<>();
@Subscribe | public void handleEvent(OrderPlacedEvent event) { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; | package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
| private static final CommandBus commandBus = mock(CommandBus.class); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; | package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
private static final CommandBus commandBus = mock(CommandBus.class); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
private static final CommandBus commandBus = mock(CommandBus.class); | private static final QueryService queryService = mock(QueryService.class); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; | package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
private static final CommandBus commandBus = mock(CommandBus.class);
private static final QueryService queryService = mock(QueryService.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new OrderResource(commandBus))
.build();
@After
public void tearDown() throws Exception {
reset(queryService, commandBus);
}
@Test
public void testCreateOrderRequest() { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
private static final CommandBus commandBus = mock(CommandBus.class);
private static final QueryService queryService = mock(QueryService.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new OrderResource(commandBus))
.build();
@After
public void tearDown() throws Exception {
reset(queryService, commandBus);
}
@Test
public void testCreateOrderRequest() { | PlaceOrderRequest newOrderRequest = new PlaceOrderRequest(); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; | package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
private static final CommandBus commandBus = mock(CommandBus.class);
private static final QueryService queryService = mock(QueryService.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new OrderResource(commandBus))
.build();
@After
public void tearDown() throws Exception {
reset(queryService, commandBus);
}
@Test
public void testCreateOrderRequest() {
PlaceOrderRequest newOrderRequest = new PlaceOrderRequest();
newOrderRequest.orderId = UUID.randomUUID().toString();
newOrderRequest.customerAddress = "Address";
newOrderRequest.customerEmail = "test@example.com";
newOrderRequest.customerName = "John Doe";
newOrderRequest.cart = createCart();
createOrder(newOrderRequest);
}
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
package se.citerus.cqrs.bookstore.ordercontext.resource;
public class OrderResourceTest {
private static final String ORDER_RESOURCE = "/order-requests";
private static final CommandBus commandBus = mock(CommandBus.class);
private static final QueryService queryService = mock(QueryService.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new OrderResource(commandBus))
.build();
@After
public void tearDown() throws Exception {
reset(queryService, commandBus);
}
@Test
public void testCreateOrderRequest() {
PlaceOrderRequest newOrderRequest = new PlaceOrderRequest();
newOrderRequest.orderId = UUID.randomUUID().toString();
newOrderRequest.customerAddress = "Address";
newOrderRequest.customerEmail = "test@example.com";
newOrderRequest.customerName = "John Doe";
newOrderRequest.cart = createCart();
createOrder(newOrderRequest);
}
| private CartDto createCart() { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; | @ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new OrderResource(commandBus))
.build();
@After
public void tearDown() throws Exception {
reset(queryService, commandBus);
}
@Test
public void testCreateOrderRequest() {
PlaceOrderRequest newOrderRequest = new PlaceOrderRequest();
newOrderRequest.orderId = UUID.randomUUID().toString();
newOrderRequest.customerAddress = "Address";
newOrderRequest.customerEmail = "test@example.com";
newOrderRequest.customerName = "John Doe";
newOrderRequest.cart = createCart();
createOrder(newOrderRequest);
}
private CartDto createCart() {
CartDto cartDto = new CartDto();
cartDto.cartId = UUID.randomUUID().toString();
cartDto.totalPrice = 1200;
cartDto.totalQuantity = 10;
cartDto.lineItems = randomLineItems();
return cartDto;
}
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/QueryService.java
// public class QueryService {
//
// private final OrderListDenormalizer orderListDenormalizer;
// private final OrdersPerDayAggregator ordersPerDayAggregator;
// private final ProductCatalogClient productCatalogClient;
//
// public QueryService(OrderListDenormalizer orderListDenormalizer,
// OrdersPerDayAggregator ordersPerDayAggregator,
// ProductCatalogClient productCatalogClient) {
// this.orderListDenormalizer = orderListDenormalizer;
// this.ordersPerDayAggregator = ordersPerDayAggregator;
// this.productCatalogClient = productCatalogClient;
// }
//
// public OrderProjection getOrder(OrderId orderId) {
// return orderListDenormalizer.get(orderId);
// }
//
// public List<OrderProjection> getOrders() {
// return orderListDenormalizer.getOrders();
// }
//
// public PublisherContractId findPublisherContract(ProductId productId) {
// ProductDto product = productCatalogClient.getProduct(productId.id);
// return new PublisherContractId(product.publisherContractId);
// }
//
// public Map<LocalDate, Integer> getOrdersPerDay() {
// return ordersPerDayAggregator.getOrdersPerDay();
// }
//
// }
// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.query.QueryService;
import javax.ws.rs.client.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new OrderResource(commandBus))
.build();
@After
public void tearDown() throws Exception {
reset(queryService, commandBus);
}
@Test
public void testCreateOrderRequest() {
PlaceOrderRequest newOrderRequest = new PlaceOrderRequest();
newOrderRequest.orderId = UUID.randomUUID().toString();
newOrderRequest.customerAddress = "Address";
newOrderRequest.customerEmail = "test@example.com";
newOrderRequest.customerName = "John Doe";
newOrderRequest.cart = createCart();
createOrder(newOrderRequest);
}
private CartDto createCart() {
CartDto cartDto = new CartDto();
cartDto.cartId = UUID.randomUUID().toString();
cartDto.totalPrice = 1200;
cartDto.totalQuantity = 10;
cartDto.lineItems = randomLineItems();
return cartDto;
}
| private List<LineItemDto> randomLineItems() { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() { | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java
import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() { | denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository()); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() { | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java
import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() { | OrderId orderId = OrderId.randomId(); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId(); | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java
import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId(); | CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address"); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId();
CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address");
| // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java
import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId();
CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address");
| OrderPlacedEvent event1 = new OrderPlacedEvent(orderId, 0, 1, customerInformation, |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId();
CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address");
OrderPlacedEvent event1 = new OrderPlacedEvent(orderId, 0, 1, customerInformation, | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java
import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId();
CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address");
OrderPlacedEvent event1 = new OrderPlacedEvent(orderId, 0, 1, customerInformation, | Collections.<OrderLine>emptyList(), 0); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java | // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId();
CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address");
OrderPlacedEvent event1 = new OrderPlacedEvent(orderId, 0, 1, customerInformation,
Collections.<OrderLine>emptyList(), 0);
denormalizer.handleEvent(event1);
| // Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
// public class InMemOrderProjectionRepository implements OrderProjectionRepository {
//
// private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
// private final Map<OrderId, OrderProjection> orders = new HashMap<>();
//
// private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
// orders.put(orderId, orderProjection);
// }
//
// @Override
// public void save(OrderProjection orderProjection) {
// saveOrder(orderProjection.getOrderId(), orderProjection);
// }
//
// @Override
// public OrderProjection getById(OrderId orderId) {
// return orders.get(orderId);
// }
//
// @Override
// public List<OrderProjection> listOrdersByTimestamp() {
// List<OrderProjection> projections = new ArrayList<>(orders.values());
// Collections.sort(projections, Collections.reverseOrder(ORDER_TIMESTAMP_COMPARATOR));
// return projections;
// }
//
// private static class OrderTimestampComparator implements Comparator<OrderProjection> {
// @Override
// public int compare(OrderProjection o1, OrderProjection o2) {
// return Long.valueOf(o1.getOrderPlacedTimestamp()).compareTo(o2.getOrderPlacedTimestamp());
// }
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/CustomerInformation.java
// public class CustomerInformation extends TransportObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(@JsonProperty("customerName") String customerName,
// @JsonProperty("email") String email,
// @JsonProperty("address") String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
//
// public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp) {
// super(aggregateId, version, timestamp);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderListDenormalizerTest.java
import org.junit.Before;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.infrastructure.InMemOrderProjectionRepository;
import se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.ACTIVATED;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public class OrderListDenormalizerTest {
private OrderListDenormalizer denormalizer;
@Before
public void setUp() {
denormalizer = new OrderListDenormalizer(new InMemOrderProjectionRepository());
}
@Test
public void activatePlacedOrderSavesStatus() {
OrderId orderId = OrderId.randomId();
CustomerInformation customerInformation = new CustomerInformation("name", "someone@acme.com", "address");
OrderPlacedEvent event1 = new OrderPlacedEvent(orderId, 0, 1, customerInformation,
Collections.<OrderLine>emptyList(), 0);
denormalizer.handleEvent(event1);
| OrderActivatedEvent event2 = new OrderActivatedEvent(orderId, 1, 2); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import static com.google.common.base.Preconditions.checkState; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContract extends AggregateRoot<PublisherContractId> {
private double feePercentage;
private long limit;
private long accumulatedFee;
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
assertHasNotBeenRegistered(); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import static com.google.common.base.Preconditions.checkState;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContract extends AggregateRoot<PublisherContractId> {
private double feePercentage;
private long limit;
private long accumulatedFee;
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
assertHasNotBeenRegistered(); | applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit)); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import static com.google.common.base.Preconditions.checkState; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContract extends AggregateRoot<PublisherContractId> {
private double feePercentage;
private long limit;
private long accumulatedFee;
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
assertHasNotBeenRegistered();
applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit));
}
| // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import static com.google.common.base.Preconditions.checkState;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContract extends AggregateRoot<PublisherContractId> {
private double feePercentage;
private long limit;
private long accumulatedFee;
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
assertHasNotBeenRegistered();
applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit));
}
| public void registerPurchase(ProductId productId, long unitPrice, int quantity) { |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
| import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import static com.google.common.base.Preconditions.checkState; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContract extends AggregateRoot<PublisherContractId> {
private double feePercentage;
private long limit;
private long accumulatedFee;
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
assertHasNotBeenRegistered();
applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit));
}
public void registerPurchase(ProductId productId, long unitPrice, int quantity) {
long purchaseAmount = unitPrice * quantity;
AccumulatedFee newFee = new AccumulatedFee(accumulatedFee, limit, feePercentage).addPurchase(purchaseAmount); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PublisherContractRegisteredEvent.java
// public class PublisherContractRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public PublisherContractRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("publisherName") String publisherName,
// @JsonProperty("feePercentage") double feePercentage,
// @JsonProperty("limit") long limit) {
// super(aggregateId, version, timestamp);
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/event/PurchaseRegisteredEvent.java
// public class PurchaseRegisteredEvent extends DomainEvent<PublisherContractId> {
//
// public final ProductId productId;
// public final long purchaseAmount;
// public final long feeAmount;
// public final long accumulatedFee;
//
// public PurchaseRegisteredEvent(@JsonProperty("aggregateId") PublisherContractId aggregateId,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("productId") ProductId productId,
// @JsonProperty("purchaseAmount") long purchaseAmount,
// @JsonProperty("feeAmount") long feeAmount,
// @JsonProperty("accumulatedFee") long accumulatedFee) {
// super(aggregateId, version, timestamp);
// this.productId = productId;
// this.purchaseAmount = purchaseAmount;
// this.feeAmount = feeAmount;
// this.accumulatedFee = accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PublisherContractRegisteredEvent;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.event.PurchaseRegisteredEvent;
import static com.google.common.base.Preconditions.checkState;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain;
public class PublisherContract extends AggregateRoot<PublisherContractId> {
private double feePercentage;
private long limit;
private long accumulatedFee;
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
assertHasNotBeenRegistered();
applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit));
}
public void registerPurchase(ProductId productId, long unitPrice, int quantity) {
long purchaseAmount = unitPrice * quantity;
AccumulatedFee newFee = new AccumulatedFee(accumulatedFee, limit, feePercentage).addPurchase(purchaseAmount); | applyChange(new PurchaseRegisteredEvent(id(), nextVersion(), now(), productId, purchaseAmount, newFee.lastPurchaseFee(), newFee.accumulatedFee())); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class PlaceOrderCommand extends Command {
public final OrderId orderId; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class PlaceOrderCommand extends Command {
public final OrderId orderId; | public final CustomerInformation customerInformation; |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class PlaceOrderCommand extends Command {
public final OrderId orderId;
public final CustomerInformation customerInformation; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class PlaceOrderCommand extends Command {
public final OrderId orderId;
public final CustomerInformation customerInformation; | public final List<OrderLine> orderLines; |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.query.sales;
public class OrdersPerDayAggregatorTest {
private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();
@Test
public void testHandleEvent() { | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java
import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.query.sales;
public class OrdersPerDayAggregatorTest {
private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();
@Test
public void testHandleEvent() { | OrderPlacedEvent book1 = createOrder(2013, 1, 1); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.query.sales;
public class OrdersPerDayAggregatorTest {
private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();
@Test
public void testHandleEvent() {
OrderPlacedEvent book1 = createOrder(2013, 1, 1);
OrderPlacedEvent book2 = createOrder(2013, 1, 2);
OrderPlacedEvent book3 = createOrder(2013, 1, 2);
ordersPerDayAggregator.handleEvent(book1);
ordersPerDayAggregator.handleEvent(book2);
ordersPerDayAggregator.handleEvent(book3);
assertThat(ordersPerDayAggregator.getOrdersPerDay().toString(), is("{2013-01-01=1, 2013-01-02=2}"));
}
private OrderPlacedEvent createOrder(int year, int month, int day) {
long timestamp = new LocalDate(year, month, day).toDate().getTime(); | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java
import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.query.sales;
public class OrdersPerDayAggregatorTest {
private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();
@Test
public void testHandleEvent() {
OrderPlacedEvent book1 = createOrder(2013, 1, 1);
OrderPlacedEvent book2 = createOrder(2013, 1, 2);
OrderPlacedEvent book3 = createOrder(2013, 1, 2);
ordersPerDayAggregator.handleEvent(book1);
ordersPerDayAggregator.handleEvent(book2);
ordersPerDayAggregator.handleEvent(book3);
assertThat(ordersPerDayAggregator.getOrdersPerDay().toString(), is("{2013-01-01=1, 2013-01-02=2}"));
}
private OrderPlacedEvent createOrder(int year, int month, int day) {
long timestamp = new LocalDate(year, month, day).toDate().getTime(); | return new OrderPlacedEvent(OrderId.<OrderId>randomId(), 1, timestamp, null, Collections.<OrderLine>emptyList(), 0); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
| import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat; | package se.citerus.cqrs.bookstore.ordercontext.query.sales;
public class OrdersPerDayAggregatorTest {
private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();
@Test
public void testHandleEvent() {
OrderPlacedEvent book1 = createOrder(2013, 1, 1);
OrderPlacedEvent book2 = createOrder(2013, 1, 2);
OrderPlacedEvent book3 = createOrder(2013, 1, 2);
ordersPerDayAggregator.handleEvent(book1);
ordersPerDayAggregator.handleEvent(book2);
ordersPerDayAggregator.handleEvent(book3);
assertThat(ordersPerDayAggregator.getOrdersPerDay().toString(), is("{2013-01-01=1, 2013-01-02=2}"));
}
private OrderPlacedEvent createOrder(int year, int month, int day) {
long timestamp = new LocalDate(year, month, day).toDate().getTime(); | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderLine.java
// public class OrderLine extends TransportObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(@JsonProperty("productId") ProductId productId,
// @JsonProperty("title") String title,
// @JsonProperty("quantity") int quantity,
// @JsonProperty("unitPrice") long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
//
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long orderAmount;
//
// public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
// @JsonProperty("version") int version,
// @JsonProperty("timestamp") long timestamp,
// @JsonProperty("customerInformation") CustomerInformation customerInformation,
// @JsonProperty("orderLines") List<OrderLine> orderLines,
// @JsonProperty("orderAmount") long orderAmount) {
// super(id, version, timestamp);
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.orderAmount = orderAmount;
// }
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java
import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.query.sales;
public class OrdersPerDayAggregatorTest {
private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();
@Test
public void testHandleEvent() {
OrderPlacedEvent book1 = createOrder(2013, 1, 1);
OrderPlacedEvent book2 = createOrder(2013, 1, 2);
OrderPlacedEvent book3 = createOrder(2013, 1, 2);
ordersPerDayAggregator.handleEvent(book1);
ordersPerDayAggregator.handleEvent(book2);
ordersPerDayAggregator.handleEvent(book3);
assertThat(ordersPerDayAggregator.getOrdersPerDay().toString(), is("{2013-01-01=1, 2013-01-02=2}"));
}
private OrderPlacedEvent createOrder(int year, int month, int day) {
long timestamp = new LocalDate(year, month, day).toDate().getTime(); | return new OrderPlacedEvent(OrderId.<OrderId>randomId(), 1, timestamp, null, Collections.<OrderLine>emptyList(), 0); |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.shopping.api;
public class CreateCartRequest extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CreateCartRequest.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.shopping.api;
public class CreateCartRequest extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public interface OrderProjectionRepository {
void save(OrderProjection orderProjection);
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.query.orderlist;
public interface OrderProjectionRepository {
void save(OrderProjection orderProjection);
| OrderProjection getById(OrderId orderId); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/OrderCommandHandler.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/Order.java
// public class Order extends AggregateRoot<OrderId> {
//
// private OrderStatus status;
//
// public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// assertHasNotBeenPlaced();
// assertMoreThanZeroOrderLines(orderLines);
// applyChange(new OrderPlacedEvent(orderId, nextVersion(), now(), toCustomerInformation(customerInformation),
// toOrderLines(orderLines), totalAmount));
// }
//
// public void activate() {
// if (orderIsPlaced()) {
// applyChange(new OrderActivatedEvent(id(), nextVersion(), now()));
// }
// }
//
// private boolean orderIsPlaced() {
// return status == OrderStatus.PLACED;
// }
//
// private void assertMoreThanZeroOrderLines(List<OrderLine> orderLines) {
// checkArgument(!orderLines.isEmpty(), "Cannot place an order without any order lines");
// }
//
// private void assertHasNotBeenPlaced() {
// checkState(id() == null, "Order has already been placed");
// }
//
// private se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation toCustomerInformation(
// CustomerInformation customerInformation) {
// return new se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation(
// customerInformation.customerName, customerInformation.email, customerInformation.address);
// }
//
// private List<se.citerus.cqrs.bookstore.ordercontext.order.OrderLine> toOrderLines(List<OrderLine> orderLines) {
// List<se.citerus.cqrs.bookstore.ordercontext.order.OrderLine> list = new ArrayList<>();
// for (OrderLine orderLine : orderLines) {
// list.add(new se.citerus.cqrs.bookstore.ordercontext.order.OrderLine(orderLine.productId, orderLine.title,
// orderLine.quantity, orderLine.unitPrice));
// }
// return list;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(OrderPlacedEvent event) {
// this.status = OrderStatus.PLACED;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(OrderActivatedEvent event) {
// this.status = OrderStatus.ACTIVATED;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.Order; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class OrderCommandHandler implements CommandHandler {
private final Repository repository;
public OrderCommandHandler(Repository repository) {
this.repository = repository;
}
@Subscribe
public void handle(PlaceOrderCommand command) { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/Order.java
// public class Order extends AggregateRoot<OrderId> {
//
// private OrderStatus status;
//
// public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// assertHasNotBeenPlaced();
// assertMoreThanZeroOrderLines(orderLines);
// applyChange(new OrderPlacedEvent(orderId, nextVersion(), now(), toCustomerInformation(customerInformation),
// toOrderLines(orderLines), totalAmount));
// }
//
// public void activate() {
// if (orderIsPlaced()) {
// applyChange(new OrderActivatedEvent(id(), nextVersion(), now()));
// }
// }
//
// private boolean orderIsPlaced() {
// return status == OrderStatus.PLACED;
// }
//
// private void assertMoreThanZeroOrderLines(List<OrderLine> orderLines) {
// checkArgument(!orderLines.isEmpty(), "Cannot place an order without any order lines");
// }
//
// private void assertHasNotBeenPlaced() {
// checkState(id() == null, "Order has already been placed");
// }
//
// private se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation toCustomerInformation(
// CustomerInformation customerInformation) {
// return new se.citerus.cqrs.bookstore.ordercontext.order.CustomerInformation(
// customerInformation.customerName, customerInformation.email, customerInformation.address);
// }
//
// private List<se.citerus.cqrs.bookstore.ordercontext.order.OrderLine> toOrderLines(List<OrderLine> orderLines) {
// List<se.citerus.cqrs.bookstore.ordercontext.order.OrderLine> list = new ArrayList<>();
// for (OrderLine orderLine : orderLines) {
// list.add(new se.citerus.cqrs.bookstore.ordercontext.order.OrderLine(orderLine.productId, orderLine.title,
// orderLine.quantity, orderLine.unitPrice));
// }
// return list;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(OrderPlacedEvent event) {
// this.status = OrderStatus.PLACED;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(OrderActivatedEvent event) {
// this.status = OrderStatus.ACTIVATED;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/OrderCommandHandler.java
import com.google.common.eventbus.Subscribe;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.Order;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class OrderCommandHandler implements CommandHandler {
private final Repository repository;
public OrderCommandHandler(Repository repository) {
this.repository = repository;
}
@Subscribe
public void handle(PlaceOrderCommand command) { | Order order = new Order(); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/PublisherContractCommandHandler.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java
// public class PublisherContract extends AggregateRoot<PublisherContractId> {
//
// private double feePercentage;
// private long limit;
// private long accumulatedFee;
//
// public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
// assertHasNotBeenRegistered();
// applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit));
// }
//
// public void registerPurchase(ProductId productId, long unitPrice, int quantity) {
// long purchaseAmount = unitPrice * quantity;
// AccumulatedFee newFee = new AccumulatedFee(accumulatedFee, limit, feePercentage).addPurchase(purchaseAmount);
// applyChange(new PurchaseRegisteredEvent(id(), nextVersion(), now(), productId, purchaseAmount, newFee.lastPurchaseFee(), newFee.accumulatedFee()));
// }
//
// private void assertHasNotBeenRegistered() {
// checkState(id() == null, "Contract has already been registered");
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(PublisherContractRegisteredEvent event) {
// this.feePercentage = event.feePercentage;
// this.limit = event.limit;
// this.accumulatedFee = 0;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(PurchaseRegisteredEvent event) {
// this.accumulatedFee = event.accumulatedFee;
// }
//
// }
| import com.google.common.eventbus.Subscribe;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain.PublisherContract; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.command;
public class PublisherContractCommandHandler implements CommandHandler {
private final Repository repository;
public PublisherContractCommandHandler(Repository repository) {
this.repository = repository;
}
@Subscribe
public void handle(RegisterPublisherContractCommand command) { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/domain/PublisherContract.java
// public class PublisherContract extends AggregateRoot<PublisherContractId> {
//
// private double feePercentage;
// private long limit;
// private long accumulatedFee;
//
// public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) {
// assertHasNotBeenRegistered();
// applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit));
// }
//
// public void registerPurchase(ProductId productId, long unitPrice, int quantity) {
// long purchaseAmount = unitPrice * quantity;
// AccumulatedFee newFee = new AccumulatedFee(accumulatedFee, limit, feePercentage).addPurchase(purchaseAmount);
// applyChange(new PurchaseRegisteredEvent(id(), nextVersion(), now(), productId, purchaseAmount, newFee.lastPurchaseFee(), newFee.accumulatedFee()));
// }
//
// private void assertHasNotBeenRegistered() {
// checkState(id() == null, "Contract has already been registered");
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(PublisherContractRegisteredEvent event) {
// this.feePercentage = event.feePercentage;
// this.limit = event.limit;
// this.accumulatedFee = 0;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// void handleEvent(PurchaseRegisteredEvent event) {
// this.accumulatedFee = event.accumulatedFee;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/PublisherContractCommandHandler.java
import com.google.common.eventbus.Subscribe;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.domain.PublisherContract;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.command;
public class PublisherContractCommandHandler implements CommandHandler {
private final Repository repository;
public PublisherContractCommandHandler(Repository repository) {
this.repository = repository;
}
@Subscribe
public void handle(RegisterPublisherContractCommand command) { | PublisherContract contract = new PublisherContract(); |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/test/java/se/citerus/cqrs/bookstore/ordercontext/application/TestContractDataImporter.java | // Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
| import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import org.junit.Ignore;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.Resources.getResource; | package se.citerus.cqrs.bookstore.ordercontext.application;
@Ignore
public class TestContractDataImporter {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final String SERVER_RESOURCE = "http://localhost:8070/service/publisher-contract-requests";
public static final String DEFAULT_PATH = "test-publisher-contracts.json";
public static void main(String[] args) {
try {
TestHttpClient publisherClient = new TestHttpClient(SERVER_RESOURCE).init();
String contractsJson = Resources.toString(getResource(DEFAULT_PATH), UTF_8); | // Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
// Path: order-context-parent/order-application/src/test/java/se/citerus/cqrs/bookstore/ordercontext/application/TestContractDataImporter.java
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import org.junit.Ignore;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.Resources.getResource;
package se.citerus.cqrs.bookstore.ordercontext.application;
@Ignore
public class TestContractDataImporter {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final String SERVER_RESOURCE = "http://localhost:8070/service/publisher-contract-requests";
public static final String DEFAULT_PATH = "test-publisher-contracts.json";
public static void main(String[] args) {
try {
TestHttpClient publisherClient = new TestHttpClient(SERVER_RESOURCE).init();
String contractsJson = Resources.toString(getResource(DEFAULT_PATH), UTF_8); | TypeReference<List<RegisterPublisherContractRequest>> listOfRegisterPublisherRequests = |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass()); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass()); | private final CommandBus commandBus; |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus; | private final CommandFactory commandFactory = new CommandFactory(); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST | public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.