Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/replay-version' into develop

  • Loading branch information...
commit 92a71d22fafa75c4572b09b5e89d277fe85e8eb8 2 parents c57da37 + 162c9b4
@mwl mwl authored
Showing with 125 additions and 84 deletions.
  1. +17 −3 ...dk/bemyndigelsesregister/bemyndigelsesservice/domain/{MessageReplay.java → MessageRetransmission.java}
  2. +11 −10 ...sesservice/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/MedcomReplayRegisterImpl.java
  3. +0 −11 ...igelsesservice/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/MessageReplayDao.java
  4. +11 −0 ...ervice/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/MessageRetransmissionDao.java
  5. +0 −17 ...ice/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageReplayDaoEbean.java
  6. +17 −0 ...main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageRetransmissionDaoEbean.java
  7. +2 −1  bemyndigelsesservice/src/main/resources/db/migration/V1__Initial_schema.sql
  8. +24 −7 ...ervice/src/test/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/MedcomReplayRegisterImplTest.java
  9. +0 −33 ...src/test/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageReplayDaoEbeanTest.java
  10. +35 −0 .../java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageRetransmissionDaoEbeanTest.java
  11. +2 −1  integration-test/src/test/groovy/bemyndigelsesservice/OpretAnmodningOmBemyndigelseITCase.groovy
  12. +6 −1 shared/src/main/java/dk/bemyndigelsesregister/shared/service/SystemServiceDefault.java
View
20 ...er/bemyndigelsesservice/domain/MessageReplay.java → ...digelsesservice/domain/MessageRetransmission.java
@@ -4,18 +4,21 @@
import javax.persistence.Lob;
@Entity
-public class MessageReplay extends DomainObject {
+public class MessageRetransmission extends DomainObject {
private String messageID;
@Lob
private String messageResponse;
+ private String implementationBuild;
+
@SuppressWarnings("UnusedDeclaration")
- public MessageReplay() {
+ public MessageRetransmission() {
}
- public MessageReplay(String messageID, String messageResponse) {
+ public MessageRetransmission(String messageID, String messageResponse, String implementationBuild) {
this.messageID = messageID;
this.messageResponse = messageResponse;
+ this.implementationBuild = implementationBuild;
}
//<editor-fold desc="GettersAndSetters">
@@ -24,6 +27,7 @@ public String getMessageID() {
return messageID;
}
+ @SuppressWarnings("UnusedDeclaration used by ebean")
public void setMessageID(String messageID) {
this.messageID = messageID;
}
@@ -32,8 +36,18 @@ public String getMessageResponse() {
return messageResponse;
}
+ @SuppressWarnings("UnusedDeclaration used by ebean")
public void setMessageResponse(String messageResponse) {
this.messageResponse = messageResponse;
}
+
+ public String getImplementationBuild() {
+ return implementationBuild;
+ }
+
+ @SuppressWarnings("UnusedDeclaration used by ebean")
+ public void setImplementationBuild(String implementationBuild) {
+ this.implementationBuild = implementationBuild;
+ }
//</editor-fold>
}
View
21 ...service/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/MedcomReplayRegisterImpl.java
@@ -2,8 +2,8 @@
import com.trifork.dgws.MedcomReplay;
import com.trifork.dgws.MedcomReplayRegister;
-import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageReplay;
-import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageReplayDao;
+import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageRetransmission;
+import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageRetransmissionDao;
import dk.bemyndigelsesregister.shared.service.SystemService;
import org.apache.log4j.Logger;
import org.springframework.oxm.Marshaller;
@@ -25,27 +25,28 @@
Unmarshaller unmarshaller;
@Inject
- MessageReplayDao messageReplayDao;
+ MessageRetransmissionDao messageRetransmissionDao;
@Inject
SystemService systemService;
@Override
public MedcomReplay getReplay(String messageID) {
- MessageReplay messageReplay = messageReplayDao.getByMessageID(messageID);
- if (messageReplay == null) {
- logger.debug("Found no MessageReplay for messageID=" + messageID);
+ //TODO: check for implementationbuild
+ MessageRetransmission messageRetransmission = messageRetransmissionDao.getByMessageIDAndImplementationBuild(messageID, systemService.getImplementationBuild());
+ if (messageRetransmission == null) {
+ logger.debug("Found no MessageRetransmission for messageID=" + messageID);
return null;
}
Object responseMessage;
try {
- responseMessage = unmarshaller.unmarshal(systemService.createXmlTransformSource(messageReplay.getMessageResponse()));
+ responseMessage = unmarshaller.unmarshal(systemService.createXmlTransformSource(messageRetransmission.getMessageResponse()));
} catch (IOException e) {
throw new RuntimeException("Could not unmarshal responseMessage", e);
}
- return new MedcomReplay(messageReplay.getMessageID(), responseMessage);
+ return new MedcomReplay(messageRetransmission.getMessageID(), responseMessage);
}
@Override
@@ -57,8 +58,8 @@ public void createReplay(String messageID, Object responseMessage) {
throw new RuntimeException("Could not marshal responseMessage", e);
}
- MessageReplay messageReplay = new MessageReplay(messageID, result.toString());
+ MessageRetransmission messageRetransmission = new MessageRetransmission(messageID, result.toString(), systemService.getImplementationBuild());
- messageReplayDao.save(messageReplay);
+ messageRetransmissionDao.save(messageRetransmission);
}
}
View
11 ...lsesservice/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/MessageReplayDao.java
@@ -1,11 +0,0 @@
-package dk.bemyndigelsesregister.bemyndigelsesservice.server.dao;
-
-import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageReplay;
-
-public interface MessageReplayDao {
- MessageReplay get(long id);
-
- void save(MessageReplay messageReplay);
-
- MessageReplay getByMessageID(String messageID);
-}
View
11 ...ice/src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/MessageRetransmissionDao.java
@@ -0,0 +1,11 @@
+package dk.bemyndigelsesregister.bemyndigelsesservice.server.dao;
+
+import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageRetransmission;
+
+public interface MessageRetransmissionDao {
+ MessageRetransmission get(long id);
+
+ void save(MessageRetransmission messageRetransmission);
+
+ MessageRetransmission getByMessageIDAndImplementationBuild(String messageID, String implementationBuild);
+}
View
17 .../src/main/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageReplayDaoEbean.java
@@ -1,17 +0,0 @@
-package dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.ebean;
-
-import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageReplay;
-import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageReplayDao;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class MessageReplayDaoEbean extends SupportDao<MessageReplay> implements MessageReplayDao {
- public MessageReplayDaoEbean() {
- super(MessageReplay.class);
- }
-
- @Override
- public MessageReplay getByMessageID(String messageID) {
- return query().where().eq("message_id", messageID).findUnique();
- }
-}
View
17 ...n/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageRetransmissionDaoEbean.java
@@ -0,0 +1,17 @@
+package dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.ebean;
+
+import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageRetransmission;
+import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageRetransmissionDao;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class MessageRetransmissionDaoEbean extends SupportDao<MessageRetransmission> implements MessageRetransmissionDao {
+ public MessageRetransmissionDaoEbean() {
+ super(MessageRetransmission.class);
+ }
+
+ @Override
+ public MessageRetransmission getByMessageIDAndImplementationBuild(String messageID, String implementationBuild) {
+ return query().where().eq("message_id", messageID).eq("implementation_build", implementationBuild).findUnique();
+ }
+}
View
3  bemyndigelsesservice/src/main/resources/db/migration/V1__Initial_schema.sql
@@ -153,12 +153,13 @@ CREATE TABLE `bemyndigelse` (
ON UPDATE NO ACTION
);
-CREATE TABLE `message_replay` (
+CREATE TABLE `message_retransmission` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`sidst_modificeret` datetime DEFAULT NULL,
`sidst_modificeret_af` varchar(255) DEFAULT NULL,
`message_id` varchar(255) NOT NULL,
`message_response` BLOB NOT NULL,
+ `implementation_build` varchar(255) NOT NULL,
PRIMARY KEY(`id`)
);
View
31 ...ice/src/test/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/MedcomReplayRegisterImplTest.java
@@ -1,8 +1,8 @@
package dk.bemyndigelsesregister.bemyndigelsesservice.server;
import com.trifork.dgws.MedcomReplay;
-import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageReplay;
-import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageReplayDao;
+import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageRetransmission;
+import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageRetransmissionDao;
import dk.bemyndigelsesregister.shared.service.SystemService;
import org.hamcrest.Description;
import org.junit.Before;
@@ -18,7 +18,7 @@
import static org.mockito.Mockito.*;
public class MedcomReplayRegisterImplTest {
- private final MessageReplayDao messageReplayDao = mock(MessageReplayDao.class);
+ private final MessageRetransmissionDao messageRetransmissionDao = mock(MessageRetransmissionDao.class);
private final MedcomReplayRegisterImpl register = new MedcomReplayRegisterImpl();
private final Marshaller marshaller = mock(Marshaller.class);
private final Unmarshaller unmarshaller = mock(Unmarshaller.class);
@@ -27,10 +27,11 @@
private final Object unmarshalledObject = "UnmarshalledObject";
private final String marshalledObject = "MarshalledObject";
private final String messageID = "MessageID";
+ private String implementationBuild = "V1";
@Before
public void setUp() throws Exception {
- register.messageReplayDao = messageReplayDao;
+ register.messageRetransmissionDao = messageRetransmissionDao;
register.marshaller = marshaller;
register.unmarshaller = unmarshaller;
register.systemService = systemService;
@@ -45,7 +46,7 @@ public void willReturnNullOnNoReplay() throws Exception {
public void willReturnMappedMedcomReplay() throws Exception {
Source source = mock(Source.class);
- when(messageReplayDao.getByMessageID(messageID)).thenReturn(new MessageReplay(messageID, marshalledObject));
+ when(messageRetransmissionDao.getByMessageIDAndImplementationBuild(messageID, null)).thenReturn(new MessageRetransmission(messageID, marshalledObject, implementationBuild));
when(systemService.createXmlTransformSource(marshalledObject)).thenReturn(source);
when(unmarshaller.unmarshal(source)).thenReturn(unmarshalledObject);
@@ -56,6 +57,22 @@ public void willReturnMappedMedcomReplay() throws Exception {
}
@Test
+ public void willNotReturnMappedMedcomRetransmissionWhenVersionHasChanged() throws Exception {
+ Source source = mock(Source.class);
+
+ when(systemService.getImplementationBuild()).thenReturn(implementationBuild);
+ when(messageRetransmissionDao.getByMessageIDAndImplementationBuild(messageID, implementationBuild)).thenReturn(new MessageRetransmission(messageID, marshalledObject, implementationBuild));
+ when(systemService.createXmlTransformSource(marshalledObject)).thenReturn(source);
+ when(unmarshaller.unmarshal(source)).thenReturn(unmarshalledObject);
+
+ MedcomReplay medcomReplay = register.getReplay(messageID);
+
+ verify(messageRetransmissionDao).getByMessageIDAndImplementationBuild(messageID, implementationBuild);
+
+ assertEquals(unmarshalledObject, medcomReplay.getResponseMessage());
+ }
+
+ @Test
public void canSaveReplay() throws Exception {
Result result = mock(Result.class);
@@ -64,9 +81,9 @@ public void canSaveReplay() throws Exception {
register.createReplay(messageID, unmarshalledObject);
- verify(messageReplayDao).save(argThat(new TypeSafeMatcher<MessageReplay>() {
+ verify(messageRetransmissionDao).save(argThat(new TypeSafeMatcher<MessageRetransmission>() {
@Override
- public boolean matchesSafely(MessageReplay item) {
+ public boolean matchesSafely(MessageRetransmission item) {
return item.getMessageID().equals(messageID) && item.getMessageResponse().equals(marshalledObject);
}
@Override
View
33 .../test/java/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageReplayDaoEbeanTest.java
@@ -1,33 +0,0 @@
-package dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.ebean;
-
-import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageReplay;
-import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageReplayDao;
-import org.junit.Test;
-
-import javax.inject.Inject;
-import java.util.UUID;
-
-import static org.junit.Assert.*;
-
-public class MessageReplayDaoEbeanTest extends DaoUnitTestSupport {
-
- @Inject
- MessageReplayDao dao;
-
- @Test
- public void willReturnNullOnNoRowsWithMessageID() throws Exception {
- assertNull(dao.getByMessageID(UUID.randomUUID().toString()));
- }
-
- @Test
- public void canFindAReplayByMessageID() throws Exception {
- String messageID = UUID.randomUUID().toString();
- MessageReplay messageReplay = new MessageReplay(messageID, "TEST");
- dao.save(messageReplay);
- assertNotNull(messageReplay.getId());
-
- MessageReplay foundMessageReplay = dao.getByMessageID(messageID);
- assertEquals(messageReplay.getMessageID(), foundMessageReplay.getMessageID());
- assertEquals(messageReplay.getMessageResponse(), foundMessageReplay.getMessageResponse());
- }
-}
View
35 ...va/dk/bemyndigelsesregister/bemyndigelsesservice/server/dao/ebean/MessageRetransmissionDaoEbeanTest.java
@@ -0,0 +1,35 @@
+package dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.ebean;
+
+import dk.bemyndigelsesregister.bemyndigelsesservice.domain.MessageRetransmission;
+import dk.bemyndigelsesregister.bemyndigelsesservice.server.dao.MessageRetransmissionDao;
+import org.junit.Test;
+
+import javax.inject.Inject;
+import java.util.UUID;
+
+import static org.junit.Assert.*;
+
+public class MessageRetransmissionDaoEbeanTest extends DaoUnitTestSupport {
+
+ @Inject
+ MessageRetransmissionDao dao;
+
+ @Test
+ public void willReturnNullOnNoRowsWithMessageID() throws Exception {
+ assertNull(dao.getByMessageIDAndImplementationBuild(UUID.randomUUID().toString(), "V1"));
+ }
+
+ @Test
+ public void canFindAReplayByMessageIDAndImplementationBuild() throws Exception {
+ String messageID = UUID.randomUUID().toString();
+ MessageRetransmission messageRetransmission = new MessageRetransmission(messageID, "TEST", "V2");
+ dao.save(messageRetransmission);
+ assertNotNull(messageRetransmission.getId());
+ dao.save(new MessageRetransmission(messageID, "TEST", "V1"));
+
+ MessageRetransmission foundMessageRetransmission = dao.getByMessageIDAndImplementationBuild(messageID, "V2");
+ assertEquals(messageRetransmission.getMessageID(), foundMessageRetransmission.getMessageID());
+ assertEquals(messageRetransmission.getMessageResponse(), foundMessageRetransmission.getMessageResponse());
+ assertEquals(messageRetransmission.getImplementationBuild(), foundMessageRetransmission.getImplementationBuild());
+ }
+}
View
3  integration-test/src/test/groovy/bemyndigelsesservice/OpretAnmodningOmBemyndigelseITCase.groovy
@@ -13,6 +13,7 @@ class OpretAnmodningOmBemyndigelseITCase extends WebServiceSupport {
@Test
public void canAccessMethod() {
SOAPClient client = getClient()
+ String messageID = UUID.randomUUID().toString()
def response = client.send(
SOAPAction: "http://web.bemyndigelsesservice.bemyndigelsesregister.dk/opretAnmodningOmBemyndigelse",
) {
@@ -21,7 +22,7 @@ class OpretAnmodningOmBemyndigelseITCase extends WebServiceSupport {
Header (xmlns:'http://www.medcom.dk/dgws/2006/04/dgws-1.0.xsd') {
Linking {
FlowID("FlowID")
- MessageID("MessageID")
+ MessageID(messageID)
}
}
}
View
7 shared/src/main/java/dk/bemyndigelsesregister/shared/service/SystemServiceDefault.java
@@ -37,7 +37,12 @@ public String getImplementationBuild() {
if (manifest == null) {
return "develop";
}
- return manifest.getMainAttributes().getValue("Implementation-Build");
+ final String implementationBuild = manifest.getMainAttributes().getValue("Implementation-Build");
+ if (implementationBuild == null) {
+ logger.warn("No Implementation-Build property found in Manifest file");
+ return "develop";
+ }
+ return implementationBuild;
}
private static Manifest manifest;
Please sign in to comment.
Something went wrong with that request. Please try again.