Skip to content

Commit

Permalink
Merge pull request #158 from scionaltera/constants-bugfix
Browse files Browse the repository at this point in the history
accidentally broke Spring by having two beans named Constants
  • Loading branch information
scionaltera authored Aug 27, 2023
2 parents 4c8f689 + 95cfa5a commit dff6188
Show file tree
Hide file tree
Showing 27 changed files with 63 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.UUID;

import static com.agonyforge.mud.core.config.SessionConfiguration.MUD_CHARACTER;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;

public abstract class AbstractCommand implements Command {
private final RepositoryBundle repositoryBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import java.util.List;

import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;

@Component
public class WhoCommand extends AbstractCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.Map;
import java.util.Objects;

import static com.agonyforge.mud.demo.model.impl.Constants.SORT_COMMAND;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_COMMAND;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_COMMAND;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_COMMAND;

public class CommandReference implements Persistent {
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import org.springframework.context.annotation.Configuration;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

@Configuration
public class Constants {
public class ModelConstants {
public static final String DB_PROPERTY = "PROPERTY#";
public static final String DB_USER = "USER#";
public static final String DB_PC = "PC#";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

import java.util.UUID;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_INSTANCE;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_INSTANCE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;

public class MudCharacter implements Persistent {
private UUID id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import java.util.Objects;
import java.util.UUID;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_ITEM;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_INSTANCE;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_ITEM;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ITEM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_INSTANCE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_ITEM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_ROOM;

public class MudItem implements Persistent {
private UUID id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.Map;
import java.util.Objects;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_PROPERTY;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PROPERTY;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_PROPERTY;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PROPERTY;

public class MudProperty implements Persistent {
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import java.util.Objects;
import java.util.stream.Collectors;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_ZONE;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ZONE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_ROOM;

public class MudRoom implements Persistent {
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import java.util.Map;
import java.util.Objects;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_ZONE;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_ZONE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ZONE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_ZONE;

public class MudZone implements Persistent {
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import java.util.Map;
import java.util.Objects;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_USER;

public class User implements Persistent {
private String principalName; // Principal name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import java.util.Map;
import java.util.Objects;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_SESSION;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_SESSION;
import static com.agonyforge.mud.models.dynamodb.impl.Constants.ISO_8601;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_SESSION;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_SESSION;
import static com.agonyforge.mud.models.dynamodb.impl.DynamoDbConstants.ISO_8601;

public class UserSession implements Persistent {
private String principalName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.Map;

import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_COMMAND;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_COMMAND;

@Repository
public class CommandRepository extends AbstractRepository<CommandReference> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import java.util.Optional;
import java.util.UUID;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_INSTANCE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_INSTANCE;

@Repository
public class MudCharacterRepository extends AbstractRepository<MudCharacter> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import java.util.Optional;
import java.util.UUID;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_ITEM;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.Constants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_INSTANCE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ITEM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_INSTANCE;

@Repository
public class MudItemRepository extends AbstractRepository<MudItem> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Map;
import java.util.Optional;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_PROPERTY;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_PROPERTY;

@Repository
public class MudPropertyRepository extends AbstractRepository<MudProperty> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.Map;
import java.util.Optional;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ROOM;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;

@Repository
public class MudRoomRepository extends AbstractRepository<MudRoom> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.Map;
import java.util.Optional;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_ZONE;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_ZONE;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;

@Repository
public class MudZoneRepository extends AbstractRepository<MudZone> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.Map;
import java.util.Optional;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.Constants.SORT_DATA;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.SORT_DATA;

@Repository
public class UserRepository extends AbstractRepository<User> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.Map;

import static com.agonyforge.mud.demo.model.impl.Constants.DB_USER;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.DB_USER;

@Repository
public class UserSessionRepository extends AbstractRepository<UserSession> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.List;
import java.util.Map;

import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;

@Component
public class CommService extends EchoService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.UUID;

import static com.agonyforge.mud.core.config.SessionConfiguration.MUD_CHARACTER;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.stream.Collectors;

import static com.agonyforge.mud.core.config.SessionConfiguration.MUD_CHARACTER;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.List;

import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Optional;
import java.util.UUID;

import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.UUID;

import static com.agonyforge.mud.core.config.SessionConfiguration.MUD_QUESTION;
import static com.agonyforge.mud.demo.model.impl.Constants.TYPE_PC;
import static com.agonyforge.mud.demo.model.impl.ModelConstants.TYPE_PC;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.text.SimpleDateFormat;

@Configuration
public class Constants {
public class DynamoDbConstants {
public static final DateFormat ISO_8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public static final String KEY_MODIFIED = "lastModified";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.Map;
import java.util.stream.Collectors;

import static com.agonyforge.mud.models.dynamodb.impl.Constants.ISO_8601;
import static com.agonyforge.mud.models.dynamodb.impl.Constants.KEY_MODIFIED;
import static com.agonyforge.mud.models.dynamodb.impl.DynamoDbConstants.ISO_8601;
import static com.agonyforge.mud.models.dynamodb.impl.DynamoDbConstants.KEY_MODIFIED;

public abstract class AbstractRepository<T extends Persistent> {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRepository.class);
Expand Down

0 comments on commit dff6188

Please sign in to comment.