Skip to content

Commit

Permalink
notification service client support
Browse files Browse the repository at this point in the history
  • Loading branch information
sqshq committed Mar 11, 2016
1 parent 01a84b2 commit fe6e87a
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 71 deletions.
2 changes: 1 addition & 1 deletion account-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM java:8-jre
ADD ./target/account-service.jar /app/
CMD ["java", "-jar", "/app/account-service.jar"]

EXPOSE 7000
EXPOSE 6000
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
public class Account {

@Id
@NotNull
@Length(min = 3, max = 20)
private String name;

private Date lastSeen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class User {

@NotNull
@Length(min = 2, max = 20)
@Length(min = 3, max = 20)
private String username;

@NotNull
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/shared/account-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ spring:

server:
context-path: /accounts
port: 7000
port: 6000
2 changes: 1 addition & 1 deletion config/src/main/resources/shared/notification-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ security:

server:
context-path: /notifications
port: 9000
port: 8000

remind:
cron: 0 0 0 * * *
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/shared/statistics-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spring:

server:
context-path: /statistics
port: 8000
port: 7000

rates:
url: http://api.fixer.io
14 changes: 7 additions & 7 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
environment:
MONGODB_PASSWORD: dev-password
ports:
- 27000:27017
- 25000:27017

account-service:
environment:
Expand All @@ -43,13 +43,13 @@ services:
ACCOUNT_SERVICE_PASSWORD: dev-password
build: account-service
ports:
- 7000:7000
- 6000:6000

account-mongodb:
environment:
MONGODB_PASSWORD: dev-password
ports:
- 27001:27017
- 26000:27017

statistics-service:
environment:
Expand All @@ -58,13 +58,13 @@ services:
STATISTICS_SERVICE_PASSWORD: dev-password
build: statistics-service
ports:
- 8000:8000
- 7000:7000

statistics-mongodb:
environment:
MONGODB_PASSWORD: dev-password
ports:
- 27002:27017
- 27000:27017

notification-service:
environment:
Expand All @@ -73,10 +73,10 @@ services:
NOTIFICATION_SERVICE_PASSWORD: dev-password
build: notification-service
ports:
- 9000:9000
- 8000:8000

notification-mongodb:
environment:
MONGODB_PASSWORD: dev-password
ports:
- 27003:27017
- 28000:27017
43 changes: 0 additions & 43 deletions gateway/src/main/resources/application.yml

This file was deleted.

2 changes: 1 addition & 1 deletion gateway/src/main/resources/static/js/login.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion notification-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM java:8-jre
ADD ./target/notification-service.jar /app/
CMD ["java", "-jar", "/app/notification-service.jar"]

EXPOSE 8888
EXPOSE 8000
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class NotificationSettings {
@NotNull
private Boolean active;

@NotNull
private Frequency frequency;

private Date lastNotified;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public Recipient findByAccountName(String accountName) {
@Override
public Recipient save(String accountName, Recipient recipient) {

Assert.isTrue(accountName.equals(recipient.getAccountName()));

recipient.setAccountName(accountName);
recipient.getScheduledNotifications().values()
.forEach(settings -> {
if (settings.getLastNotified() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,17 @@ public void shouldSaveRecipient() {
backup.setLastNotified(new Date());

Recipient recipient = new Recipient();
recipient.setAccountName("test");
recipient.setEmail("[email protected]");
recipient.setScheduledNotifications(ImmutableMap.of(
NotificationType.BACKUP, backup,
NotificationType.REMIND, remind
));

Recipient saved = recipientService.save(recipient.getAccountName(), recipient);
verify(repository).save(recipient);
Recipient saved = recipientService.save("test", recipient);

verify(repository).save(recipient);
assertNotNull(saved.getScheduledNotifications().get(NotificationType.REMIND).getLastNotified());
}

@Test(expected = IllegalArgumentException.class)
public void shouldFailToSaveRecipientWhenGivenAccountNameAndRecepientNameNotMatch() {
Recipient recipient = new Recipient();
recipient.setAccountName("test2");
recipientService.save("test1", recipient);
assertEquals("test", saved.getAccountName());
}

@Test
Expand Down

0 comments on commit fe6e87a

Please sign in to comment.