From aeeb896d7d42672bd2382af92fa1ead5c3c08aeb Mon Sep 17 00:00:00 2001 From: Benn Simon Date: Wed, 9 Feb 2022 14:23:15 +0300 Subject: [PATCH] update dependencies (#71) * fix conflicts * update spring version * update atomfeed dependency update server core dependency --- pom.xml | 23 +++---- .../java/org/opensrp/connector/HttpUtils.java | 10 +-- .../atomfeed/AllFailedEventsCouchImpl.java | 18 +++++- .../atomfeed/AllFailedEventsInMemoryImpl.java | 18 +++++- .../atomfeed/AllMarkersCouchImpl.java | 8 ++- .../atomfeed/AllMarkersInMemoryImpl.java | 9 ++- .../opensrp/connector/dhis2/ChildTracker.java | 1 - .../connector/openmrs/EncounterAtomfeed.java | 9 ++- .../connector/openmrs/PatientAtomfeed.java | 5 +- .../AllFailedEventsInMemoryImplTest.java | 30 +++++++++ .../atomfeed/AllMarkersInMemoryImplTest.java | 20 ++++++ .../it/AllFailedEventsCouchImplTest.java | 17 +++++ .../atomfeed/it/AllMarkersCouchImplTest.java | 6 ++ .../connector/openmrs/AtomFeedTest.java | 4 +- .../openmrs/service/TestResourceLoader.java | 2 +- .../service/it/TestLoggerAppender.java | 31 ---------- ...t-applicationContext-opensrp-connector.xml | 62 ++++++++++--------- 17 files changed, 177 insertions(+), 96 deletions(-) create mode 100644 src/test/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImplTest.java create mode 100644 src/test/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImplTest.java delete mode 100644 src/test/java/org/opensrp/connector/openmrs/service/it/TestLoggerAppender.java diff --git a/pom.xml b/pom.xml index a1322b1..5e165d9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ opensrp-server-connector jar - 2.3.6-SNAPSHOT + 2.4.0-SNAPSHOT opensrp-server-connector OpenSRP Server Connector module http://github.com/OpenSRP/opensrp-server-connector @@ -15,12 +15,10 @@ ${project.basedir} UTF-8 1.5.1 - 5.2.3.RELEASE - 1.0.6-SNAPSHOT - 2.12.23-SNAPSHOT + 5.2.19.RELEASE + 2.13.0-SNAPSHOT 2.0.5 1.18.12 - @@ -83,11 +81,6 @@ - - org.smartregister - opensrp-server-api - ${opensrp.api.version} - org.smartregister opensrp-server-core @@ -101,7 +94,7 @@ org.ict4h atomfeed-client - 1.9.1 + 1.9.5 org.bouncycastle @@ -114,9 +107,9 @@ 1.70 - com.squareup.okhttp + com.squareup.okhttp3 okhttp - 2.7.5 + 4.9.3 org.ektorp @@ -129,11 +122,11 @@ ${lombok.version} provided - + junit junit - 4.13.1 + 4.13.2 test diff --git a/src/main/java/org/opensrp/connector/HttpUtils.java b/src/main/java/org/opensrp/connector/HttpUtils.java index fb49a0b..25944dc 100644 --- a/src/main/java/org/opensrp/connector/HttpUtils.java +++ b/src/main/java/org/opensrp/connector/HttpUtils.java @@ -5,15 +5,15 @@ import java.io.IOException; +import okhttp3.Call; +import okhttp3.Credentials; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.squareup.okhttp.Call; -import com.squareup.okhttp.Credentials; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; /** * @author Samuel Githengi created on 09/10/20 diff --git a/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsCouchImpl.java b/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsCouchImpl.java index 2cb49ee..691f0f2 100644 --- a/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsCouchImpl.java +++ b/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsCouchImpl.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.NotImplementedException; import org.ektorp.ComplexKey; import org.ektorp.CouchDbConnector; import org.ektorp.support.View; @@ -92,7 +93,22 @@ public void remove(FailedEvent failedEvent) { public void insert(FailedEventRetryLog failedEventRetryLog) { } - + + @Override + public List getFailedEvents(String s) { + throw new NotImplementedException(); + } + + @Override + public FailedEvent getByEventId(String s) { + throw new NotImplementedException(); + } + + @Override + public List getFailedEventRetryLogs(String s) { + throw new NotImplementedException(); + } + public class AllFailedEventInnerRepository extends BaseRepository { AllFailedEventInnerRepository(CouchDbConnector db) { diff --git a/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImpl.java b/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImpl.java index da90b15..9a01337 100644 --- a/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImpl.java +++ b/src/main/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImpl.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.List; +import org.apache.commons.lang3.NotImplementedException; import org.ict4h.atomfeed.client.domain.FailedEvent; import org.ict4h.atomfeed.client.domain.FailedEventRetryLog; import org.ict4h.atomfeed.client.repository.AllFailedEvents; @@ -97,5 +98,20 @@ public void remove(FailedEvent failedEvent) { public void insert(FailedEventRetryLog failedEventRetryLog) { } - + + @Override + public List getFailedEvents(String s) { + throw new NotImplementedException(); + } + + @Override + public FailedEvent getByEventId(String s) { + throw new NotImplementedException(); + } + + @Override + public List getFailedEventRetryLogs(String s) { + throw new NotImplementedException(); + } + } diff --git a/src/main/java/org/opensrp/connector/atomfeed/AllMarkersCouchImpl.java b/src/main/java/org/opensrp/connector/atomfeed/AllMarkersCouchImpl.java index ea319d6..a52206f 100644 --- a/src/main/java/org/opensrp/connector/atomfeed/AllMarkersCouchImpl.java +++ b/src/main/java/org/opensrp/connector/atomfeed/AllMarkersCouchImpl.java @@ -4,6 +4,7 @@ import java.net.URISyntaxException; import java.util.List; +import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; import org.ektorp.CouchDbConnector; import org.ektorp.support.GenerateView; @@ -72,5 +73,10 @@ public void put(URI feedUri, String entryId, URI entryFeedUri) { add(doc); } } - + + @Override + public List getMarkerList() { + throw new NotImplementedException(); + } + } diff --git a/src/main/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImpl.java b/src/main/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImpl.java index 7680de3..95c12d0 100644 --- a/src/main/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImpl.java +++ b/src/main/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImpl.java @@ -2,7 +2,9 @@ import java.net.URI; import java.util.HashMap; +import java.util.List; +import org.apache.commons.lang3.NotImplementedException; import org.ict4h.atomfeed.client.domain.Marker; import org.ict4h.atomfeed.client.repository.AllMarkers; import org.springframework.context.annotation.Profile; @@ -26,5 +28,10 @@ public Marker get(URI feedUri) { public void put(URI feedUri, String entryId, URI entryFeedUri) { map.put(feedUri, new Marker(feedUri, entryId, entryFeedUri)); } - + + @Override + public List getMarkerList() { + throw new NotImplementedException(); + } + } diff --git a/src/main/java/org/opensrp/connector/dhis2/ChildTracker.java b/src/main/java/org/opensrp/connector/dhis2/ChildTracker.java index 0ee3146..c81647c 100644 --- a/src/main/java/org/opensrp/connector/dhis2/ChildTracker.java +++ b/src/main/java/org/opensrp/connector/dhis2/ChildTracker.java @@ -17,7 +17,6 @@ import org.smartregister.domain.Obs; import org.opensrp.service.ClientService; import org.opensrp.service.EventService; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/main/java/org/opensrp/connector/openmrs/EncounterAtomfeed.java b/src/main/java/org/opensrp/connector/openmrs/EncounterAtomfeed.java index 20d2f2a..b3f0ac4 100644 --- a/src/main/java/org/opensrp/connector/openmrs/EncounterAtomfeed.java +++ b/src/main/java/org/opensrp/connector/openmrs/EncounterAtomfeed.java @@ -9,7 +9,8 @@ import org.ict4h.atomfeed.client.repository.AllFailedEvents; import org.ict4h.atomfeed.client.repository.AllFeeds; import org.ict4h.atomfeed.client.repository.AllMarkers; -import org.ict4h.atomfeed.client.repository.datasource.WebClient; +import org.ict4h.atomfeed.client.repository.datasource.DefaultHttpClient; +import org.ict4h.atomfeed.client.repository.datasource.HttpClient; import org.ict4h.atomfeed.client.service.AtomFeedClient; import org.ict4h.atomfeed.client.service.EventWorker; import org.ict4h.atomfeed.transaction.AFTransactionManager; @@ -37,9 +38,7 @@ public class EncounterAtomfeed extends OpenmrsService implements EventWorker, At private AtomFeedProperties atomFeedProperties; private AFTransactionManager transactionManager; - - private WebClient webClient; - + private AtomFeedClient client; private EncounterService encounterService; @@ -62,7 +61,7 @@ public T executeWithTransaction(AFTransactionWork action) throws RuntimeE return action.execute(); } }; - this.webClient = new WebClient(); + HttpClient webClient = new DefaultHttpClient(); URI uri = new URI(OPENMRS_BASE_URL + OpenmrsConstants.ATOMFEED_URL + CATEGORY_URL); this.client = new AtomFeedClient(new AllFeeds(webClient), allMarkers, allFailedEvents, atomFeedProperties, diff --git a/src/main/java/org/opensrp/connector/openmrs/PatientAtomfeed.java b/src/main/java/org/opensrp/connector/openmrs/PatientAtomfeed.java index df36926..2d76101 100644 --- a/src/main/java/org/opensrp/connector/openmrs/PatientAtomfeed.java +++ b/src/main/java/org/opensrp/connector/openmrs/PatientAtomfeed.java @@ -17,7 +17,8 @@ import org.ict4h.atomfeed.client.repository.AllFailedEvents; import org.ict4h.atomfeed.client.repository.AllFeeds; import org.ict4h.atomfeed.client.repository.AllMarkers; -import org.ict4h.atomfeed.client.repository.datasource.WebClient; +import org.ict4h.atomfeed.client.repository.datasource.DefaultHttpClient; +import org.ict4h.atomfeed.client.repository.datasource.HttpClient; import org.ict4h.atomfeed.client.service.AtomFeedClient; import org.ict4h.atomfeed.client.service.EventWorker; import org.ict4h.atomfeed.transaction.AFTransactionManager; @@ -74,7 +75,7 @@ public T executeWithTransaction(AFTransactionWork action) throws RuntimeE return action.execute(); } }; - WebClient webClient = new WebClient(); + HttpClient webClient = new DefaultHttpClient(); URI uri = new URI(OPENMRS_BASE_URL + OpenmrsConstants.ATOMFEED_URL + CATEGORY_URL); this.client = new AtomFeedClient(new AllFeeds(webClient), allMarkers, allFailedEvents, atomFeedProperties, diff --git a/src/test/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImplTest.java b/src/test/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImplTest.java new file mode 100644 index 0000000..3e32e40 --- /dev/null +++ b/src/test/java/org/opensrp/connector/atomfeed/AllFailedEventsInMemoryImplTest.java @@ -0,0 +1,30 @@ +package org.opensrp.connector.atomfeed; + +import org.apache.commons.lang3.NotImplementedException; +import org.junit.Before; +import org.junit.Test; + +public class AllFailedEventsInMemoryImplTest { + + private AllFailedEventsInMemoryImpl allFailedEventsInMemory; + + @Before + public void setUp() { + allFailedEventsInMemory = new AllFailedEventsInMemoryImpl(); + } + + @Test(expected = NotImplementedException.class) + public void testGetFailedEventRetryLogsShouldReturnNotImplementedException() { + allFailedEventsInMemory.getFailedEventRetryLogs("id"); + } + + @Test(expected = NotImplementedException.class) + public void testGetFailedEventsShouldReturnNotImplementedException() { + allFailedEventsInMemory.getFailedEvents("id"); + } + + @Test(expected = NotImplementedException.class) + public void testGetByEventIdShouldReturnNotImplementedException() { + allFailedEventsInMemory.getByEventId("id"); + } +} diff --git a/src/test/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImplTest.java b/src/test/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImplTest.java new file mode 100644 index 0000000..087fdbc --- /dev/null +++ b/src/test/java/org/opensrp/connector/atomfeed/AllMarkersInMemoryImplTest.java @@ -0,0 +1,20 @@ +package org.opensrp.connector.atomfeed; + +import org.apache.commons.lang3.NotImplementedException; +import org.junit.Before; +import org.junit.Test; + +public class AllMarkersInMemoryImplTest { + + private AllMarkersInMemoryImpl allMarkersInMemory; + + @Before + public void setup(){ + allMarkersInMemory = new AllMarkersInMemoryImpl(); + } + + @Test(expected = NotImplementedException.class) + public void testGetMarkerListShouldReturnNotImplementedException() { + allMarkersInMemory.getMarkerList(); + } +} diff --git a/src/test/java/org/opensrp/connector/atomfeed/it/AllFailedEventsCouchImplTest.java b/src/test/java/org/opensrp/connector/atomfeed/it/AllFailedEventsCouchImplTest.java index 2963b67..ec689c5 100644 --- a/src/test/java/org/opensrp/connector/atomfeed/it/AllFailedEventsCouchImplTest.java +++ b/src/test/java/org/opensrp/connector/atomfeed/it/AllFailedEventsCouchImplTest.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.NotImplementedException; import org.ektorp.CouchDbInstance; import org.ektorp.http.HttpClient; import org.ektorp.http.StdHttpClient; @@ -125,4 +126,20 @@ public void testGetNumberOfFailedEvents() { assertEquals(expectedCount, actualCount); allFailedEventsCouchImpl.remove(failedEvent); } + + @Test(expected = NotImplementedException.class) + public void testGetFailedEventsShouldReturnNotImplementedException() { + allFailedEventsCouchImpl.getFailedEvents("id"); + } + + @Test + public void testGetByEventIdShouldReturnNotImplementedException() { + allFailedEventsCouchImpl.getByEventId("id"); + } + + @Test + public void testGetFailedEventRetryLogsShouldReturnNotImplementedException() { + allFailedEventsCouchImpl.getFailedEventRetryLogs("id"); + } + } diff --git a/src/test/java/org/opensrp/connector/atomfeed/it/AllMarkersCouchImplTest.java b/src/test/java/org/opensrp/connector/atomfeed/it/AllMarkersCouchImplTest.java index e908b0a..b411e46 100644 --- a/src/test/java/org/opensrp/connector/atomfeed/it/AllMarkersCouchImplTest.java +++ b/src/test/java/org/opensrp/connector/atomfeed/it/AllMarkersCouchImplTest.java @@ -8,6 +8,7 @@ import java.net.URISyntaxException; import java.util.List; +import org.apache.commons.lang3.NotImplementedException; import org.ektorp.CouchDbInstance; import org.ektorp.http.HttpClient; import org.ektorp.http.StdHttpClient; @@ -99,4 +100,9 @@ public void testFindAllMarkers() throws URISyntaxException { assertNotSame(expectedSize, marker.size()); allMarkersCouchImpl.removeAll(); } + + @Test(expected = NotImplementedException.class) + public void testGetMarkerListShouldReturnNotImplementedException() { + allMarkersCouchImpl.getMarkerList(); + } } diff --git a/src/test/java/org/opensrp/connector/openmrs/AtomFeedTest.java b/src/test/java/org/opensrp/connector/openmrs/AtomFeedTest.java index ed6c2e1..adcdd32 100644 --- a/src/test/java/org/opensrp/connector/openmrs/AtomFeedTest.java +++ b/src/test/java/org/opensrp/connector/openmrs/AtomFeedTest.java @@ -9,7 +9,7 @@ import java.util.Map; import org.ict4h.atomfeed.client.AtomFeedProperties; -import org.ict4h.atomfeed.client.repository.datasource.WebClient; +import org.ict4h.atomfeed.client.repository.datasource.HttpClient; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -40,7 +40,7 @@ public void setup() { @Test public void shouldReadEventsCreatedEvents() throws URISyntaxException { - WebClient wc = Mockito.mock(WebClient.class); + HttpClient wc = Mockito.mock(HttpClient.class); Map m = any(); when(wc.fetch(any(URI.class), any(AtomFeedProperties.class), m)).thenReturn( " Patient AOP OpenMRS bec795b1-3d17-451d-b43e-a094019f6984+1 OpenMRS Feed Publisher 2016-03-09T14:47:58Z Patient tag:atomfeed.ict4h.org:f376d71e-6ddd-465e-b224-bbe624cbf97f 2016-03-09T14:47:58Z 2016-03-09T14:47:58Z "); diff --git a/src/test/java/org/opensrp/connector/openmrs/service/TestResourceLoader.java b/src/test/java/org/opensrp/connector/openmrs/service/TestResourceLoader.java index 5a9cd4c..8c28fa5 100644 --- a/src/test/java/org/opensrp/connector/openmrs/service/TestResourceLoader.java +++ b/src/test/java/org/opensrp/connector/openmrs/service/TestResourceLoader.java @@ -27,7 +27,7 @@ public class TestResourceLoader { protected String couchDBPassword; public TestResourceLoader() throws IOException { - Resource resource = new ClassPathResource("/opensrp.properties"); + Resource resource = new ClassPathResource("opensrp.properties"); Properties props = PropertiesLoaderUtils.loadProperties(resource); openmrsOpenmrsUrl = props.getProperty("openmrs.url"); openmrsUsername = props.getProperty("openmrs.username"); diff --git a/src/test/java/org/opensrp/connector/openmrs/service/it/TestLoggerAppender.java b/src/test/java/org/opensrp/connector/openmrs/service/it/TestLoggerAppender.java deleted file mode 100644 index 0853a54..0000000 --- a/src/test/java/org/opensrp/connector/openmrs/service/it/TestLoggerAppender.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opensrp.connector.openmrs.service.it; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; - -public class TestLoggerAppender extends AppenderSkeleton { - - private final List log = new ArrayList(); - - @Override - public boolean requiresLayout() { - return false; - } - - @Override - protected void append(final LoggingEvent loggingEvent) { - log.add(loggingEvent); - } - - @Override - public void close() { - System.err.println("close"); - } - - public List getLog() { - return new ArrayList(log); - } -} diff --git a/src/test/resources/test-applicationContext-opensrp-connector.xml b/src/test/resources/test-applicationContext-opensrp-connector.xml index 38b654b..ad11aff 100644 --- a/src/test/resources/test-applicationContext-opensrp-connector.xml +++ b/src/test/resources/test-applicationContext-opensrp-connector.xml @@ -7,21 +7,23 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd"> + location="classpath:maven.properties,classpath:opensrp.properties" /> - - - - - - - - - - - + + + + + + + + + + + + + + @@ -58,24 +60,24 @@ - - - - - - - - + + + + + + + + - - - - - - + + + + + + - - - + + +