From f9802e23191d5c262313d955651a46e0bcdbf898 Mon Sep 17 00:00:00 2001 From: Rahul Ramesh Date: Thu, 26 Oct 2023 12:00:54 +0530 Subject: [PATCH] [Parvathy, Rahul] | Fix. MockMvc Import Issue --- .../openerp/client/OpenERPCustomerFeedIT.java | 2 + .../encounter/MapERPOrdersTest.java | 162 ++++---- .../feed/openerp/server/AtomFeedServerIT.java | 376 +++++++++--------- .../feed/openerp/utils/MVCTestUtils.java | 20 +- .../OpenERPDrugServiceEventWorkerTest.java | 2 + .../worker/OpenERPSaleOrderEventWorkerIT.java | 2 + .../service/CustomerAccountServiceTest.java | 2 + .../web/service/CustomerServiceTest.java | 2 + .../web/service/OpenERPServiceTest.java | 2 + .../org/bahmni/test/utils/MVCTestUtils.java | 20 +- 10 files changed, 301 insertions(+), 289 deletions(-) diff --git a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/client/OpenERPCustomerFeedIT.java b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/client/OpenERPCustomerFeedIT.java index 5b202bfe..8ce6af05 100644 --- a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/client/OpenERPCustomerFeedIT.java +++ b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/client/OpenERPCustomerFeedIT.java @@ -1,3 +1,5 @@ +// TODO : Mockito Matchers Import Issue To Be Resolved + // package org.bahmni.feed.openerp.client; // import com.sun.syndication.feed.atom.Content; diff --git a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/domain/labOrderType/encounter/MapERPOrdersTest.java b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/domain/labOrderType/encounter/MapERPOrdersTest.java index 78302ece..9ec4fbfe 100644 --- a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/domain/labOrderType/encounter/MapERPOrdersTest.java +++ b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/domain/labOrderType/encounter/MapERPOrdersTest.java @@ -1,81 +1,81 @@ -// package org.bahmni.feed.openerp.domain.labOrderType.encounter; - -// import org.bahmni.feed.openerp.ObjectMapperRepository; -// import org.bahmni.feed.openerp.domain.encounter.MapERPOrders; -// import org.bahmni.feed.openerp.domain.encounter.OpenMRSEncounter; -// import org.bahmni.feed.openerp.domain.visit.OpenMRSVisit; -// import org.bahmni.feed.openerp.testhelper.FileConverter; -// import org.bahmni.openerp.web.request.builder.Parameter; -// import org.junit.Assert; -// import org.junit.Before; -// import org.junit.Test; -// import org.junit.runner.RunWith; -// import org.mockito.Mock; -// import org.mockito.runners.MockitoJUnitRunner; - -// import java.io.IOException; -// import java.util.List; - -// import static org.mockito.Mockito.when; - -// @RunWith(MockitoJUnitRunner.class) -// public class MapERPOrdersTest { - -// private MapERPOrders mapERPOrders; - -// @Mock -// private OpenMRSEncounter openMRSEncounter; - -// @Mock -// private OpenMRSVisit openMRSVisit; - -// @Before -// public void setUp() { -// mapERPOrders = new MapERPOrders(openMRSEncounter, openMRSVisit); -// } - -// @Test -// public void shouldMapOpenERPOrders() throws IOException { -// when(openMRSEncounter.getPatientId()).thenReturn("12345"); -// when(openMRSEncounter.getEncounterUuid()).thenReturn("r5d6789uyt32"); -// when(openMRSEncounter.getLocationName()).thenReturn("Ganyari"); -// List parameterList = mapERPOrders.getParameters("102", "something", "somethingelse"); - -// Assert.assertEquals(8, parameterList.size()); -// Assert.assertEquals("create.sale.order", parameterList.get(0).getValue()); -// Assert.assertEquals("12345", parameterList.get(1).getValue()); -// Assert.assertEquals("r5d6789uyt32", parameterList.get(2).getValue()); -// Assert.assertEquals("Ganyari", parameterList.get(7).getValue()); -// } - -// @Test -// public void shouldMapEncountersWithObsCodedUnRelatedToOrders() throws Exception { -// String orderEncounter = FileConverter.convertToString("orderWithEncObsWithCodedConceptUnRelatedToOrder.json"); -// OpenMRSEncounter encounter = ObjectMapperRepository.objectMapper.readValue(orderEncounter, OpenMRSEncounter.class); -// MapERPOrders mapERPOrders = new MapERPOrders(encounter, openMRSVisit); -// List parameters = mapERPOrders.getParameters("102", "something", "somethingelse"); -// Assert.assertEquals(8, parameters.size()); -// } - -// @Test -// public void shouldMapEncountersWithObsNumericUnRelatedToOrders() throws Exception { -// String orderEncounter = FileConverter.convertToString("orderWithEncObsOfNumericUnRelatedOrder.json"); -// OpenMRSEncounter encounter = ObjectMapperRepository.objectMapper.readValue(orderEncounter, OpenMRSEncounter.class); -// MapERPOrders mapERPOrders = new MapERPOrders(encounter, openMRSVisit); -// List parameters = mapERPOrders.getParameters("102", "something", "somethingelse"); -// Assert.assertEquals(8, parameters.size()); -// } - -// @Test -// public void shouldMapEncountersWithObsDispensedRelatedToOrders() throws Exception { -// String orderEncounter = FileConverter.convertToString("orderWithEncObsCodedWithDispensedRelatedToOrder.json"); -// OpenMRSEncounter encounter = ObjectMapperRepository.objectMapper.readValue(orderEncounter, OpenMRSEncounter.class); -// MapERPOrders mapERPOrders = new MapERPOrders(encounter, openMRSVisit); -// List parameters = mapERPOrders.getParameters("102", "something", "somethingelse"); -// Assert.assertEquals(8, parameters.size()); -// } - - - - -// } \ No newline at end of file +package org.bahmni.feed.openerp.domain.labOrderType.encounter; + +import org.bahmni.feed.openerp.ObjectMapperRepository; +import org.bahmni.feed.openerp.domain.encounter.MapERPOrders; +import org.bahmni.feed.openerp.domain.encounter.OpenMRSEncounter; +import org.bahmni.feed.openerp.domain.visit.OpenMRSVisit; +import org.bahmni.feed.openerp.testhelper.FileConverter; +import org.bahmni.openerp.web.request.builder.Parameter; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +import java.io.IOException; +import java.util.List; + +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class MapERPOrdersTest { + + private MapERPOrders mapERPOrders; + + @Mock + private OpenMRSEncounter openMRSEncounter; + + @Mock + private OpenMRSVisit openMRSVisit; + + @Before + public void setUp() { + mapERPOrders = new MapERPOrders(openMRSEncounter, openMRSVisit); + } + + @Test + public void shouldMapOpenERPOrders() throws IOException { + when(openMRSEncounter.getPatientId()).thenReturn("12345"); + when(openMRSEncounter.getEncounterUuid()).thenReturn("r5d6789uyt32"); + when(openMRSEncounter.getLocationName()).thenReturn("Ganyari"); + List parameterList = mapERPOrders.getParameters("102", "something", "somethingelse"); + + Assert.assertEquals(8, parameterList.size()); + Assert.assertEquals("create.sale.order", parameterList.get(0).getValue()); + Assert.assertEquals("12345", parameterList.get(1).getValue()); + Assert.assertEquals("r5d6789uyt32", parameterList.get(2).getValue()); + Assert.assertEquals("Ganyari", parameterList.get(7).getValue()); + } + + @Test + public void shouldMapEncountersWithObsCodedUnRelatedToOrders() throws Exception { + String orderEncounter = FileConverter.convertToString("orderWithEncObsWithCodedConceptUnRelatedToOrder.json"); + OpenMRSEncounter encounter = ObjectMapperRepository.objectMapper.readValue(orderEncounter, OpenMRSEncounter.class); + MapERPOrders mapERPOrders = new MapERPOrders(encounter, openMRSVisit); + List parameters = mapERPOrders.getParameters("102", "something", "somethingelse"); + Assert.assertEquals(8, parameters.size()); + } + + @Test + public void shouldMapEncountersWithObsNumericUnRelatedToOrders() throws Exception { + String orderEncounter = FileConverter.convertToString("orderWithEncObsOfNumericUnRelatedOrder.json"); + OpenMRSEncounter encounter = ObjectMapperRepository.objectMapper.readValue(orderEncounter, OpenMRSEncounter.class); + MapERPOrders mapERPOrders = new MapERPOrders(encounter, openMRSVisit); + List parameters = mapERPOrders.getParameters("102", "something", "somethingelse"); + Assert.assertEquals(8, parameters.size()); + } + + @Test + public void shouldMapEncountersWithObsDispensedRelatedToOrders() throws Exception { + String orderEncounter = FileConverter.convertToString("orderWithEncObsCodedWithDispensedRelatedToOrder.json"); + OpenMRSEncounter encounter = ObjectMapperRepository.objectMapper.readValue(orderEncounter, OpenMRSEncounter.class); + MapERPOrders mapERPOrders = new MapERPOrders(encounter, openMRSVisit); + List parameters = mapERPOrders.getParameters("102", "something", "somethingelse"); + Assert.assertEquals(8, parameters.size()); + } + + + + +} \ No newline at end of file diff --git a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/server/AtomFeedServerIT.java b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/server/AtomFeedServerIT.java index 271c46ea..70346446 100644 --- a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/server/AtomFeedServerIT.java +++ b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/server/AtomFeedServerIT.java @@ -1,194 +1,194 @@ -// package org.bahmni.feed.openerp.server; - -// import org.bahmni.feed.openerp.repository.DbEventRecordCreator; -// import org.bahmni.feed.openerp.utils.MVCTestUtils; -// import org.ict4h.atomfeed.Configuration; -// import org.ict4h.atomfeed.IntegrationTest; -// import org.ict4h.atomfeed.client.service.AtomFeedClient; -// import org.ict4h.atomfeed.jdbc.JdbcConnectionProvider; -// import org.ict4h.atomfeed.jdbc.JdbcUtils; -// import org.ict4h.atomfeed.server.domain.EventRecord; -// import org.ict4h.atomfeed.server.exceptions.AtomFeedRuntimeException; -// import org.ict4h.atomfeed.server.repository.jdbc.AllEventRecordsJdbcImpl; -// import org.ict4h.atomfeed.server.transaction.AtomFeedSpringTransactionSupport; -// import org.ict4h.atomfeed.spring.resource.EventResource; -// import org.ict4h.atomfeed.transaction.AFTransactionWork; -// import org.junit.After; -// import org.junit.Before; -// import org.junit.Test; -// import org.junit.runner.RunWith; -// import org.springframework.beans.factory.annotation.Autowired; -// import org.springframework.test.context.ContextConfiguration; -// import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -// import org.springframework.test.web.server.ResultMatcher; - -// import java.net.URISyntaxException; -// import java.sql.*; -// import java.util.ArrayList; -// import java.util.List; -// import java.util.UUID; - -// import static org.junit.matchers.JUnitMatchers.containsString; -// import static org.springframework.test.web.server.request.MockMvcRequestBuilders.get; -// import static org.springframework.test.web.server.result.MockMvcResultMatchers.content; - -// @RunWith(SpringJUnit4ClassRunner.class) -// @ContextConfiguration(locations = { "classpath*:applicationContext-openerpTest.xml"}) -// public class AtomFeedServerIT extends IntegrationTest { - -// private DbEventRecordCreator recordCreator; -// private OpenERPAllEventRecordsJdbcImpl eventRecords; - -// @Autowired -// private AtomFeedSpringTransactionSupport transactionSupport; +package org.bahmni.feed.openerp.server; + +import org.bahmni.feed.openerp.repository.DbEventRecordCreator; +import org.bahmni.feed.openerp.utils.MVCTestUtils; +import org.ict4h.atomfeed.Configuration; +import org.ict4h.atomfeed.IntegrationTest; +import org.ict4h.atomfeed.client.service.AtomFeedClient; +import org.ict4h.atomfeed.jdbc.JdbcConnectionProvider; +import org.ict4h.atomfeed.jdbc.JdbcUtils; +import org.ict4h.atomfeed.server.domain.EventRecord; +import org.ict4h.atomfeed.server.exceptions.AtomFeedRuntimeException; +import org.ict4h.atomfeed.server.repository.jdbc.AllEventRecordsJdbcImpl; +import org.ict4h.atomfeed.server.transaction.AtomFeedSpringTransactionSupport; +import org.ict4h.atomfeed.spring.resource.EventResource; +import org.ict4h.atomfeed.transaction.AFTransactionWork; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.ResultMatcher; + +import java.net.URISyntaxException; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static org.junit.matchers.JUnitMatchers.containsString; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:applicationContext-openerpTest.xml"}) +public class AtomFeedServerIT extends IntegrationTest { + + private DbEventRecordCreator recordCreator; + private OpenERPAllEventRecordsJdbcImpl eventRecords; + + @Autowired + private AtomFeedSpringTransactionSupport transactionSupport; -// String contents =" \n" + -// " Hello, DiscWorld6\n" + -// " \n" + -// " tag:atomfeed.ict4h.org:062df21f-62e7-405b-9c80-93d7e7a7b4f6\n" + -// " 2013-07-02T03:16:30Z\n" + -// " \n" + -// " \n" + -// " \n" + -// " Hello, DiscWorld7\n" + -// " \n" + -// " tag:atomfeed.ict4h.org:4db7d280-8f64-4470-9d2b-180316034753\n" + -// " 2013-07-02T03:16:30Z\n" + -// " \n" + -// " \n"; - -// @Autowired -// private EventResource eventResource; - -// @Before -// public void before() throws SQLException { -// eventRecords = new OpenERPAllEventRecordsJdbcImpl(transactionSupport); -// recordCreator = new DbEventRecordCreator(eventRecords); -// } - -// @After -// public void after() throws SQLException { -// transactionSupport.executeWithTransaction(new AFTransactionWork() { -// @Override -// public Object execute() { -// try { -// Connection connection = transactionSupport.getConnection(); -// Statement statement = connection.createStatement(); -// statement.execute("TRUNCATE public.event_records RESTART IDENTITY;"); -// statement.close(); -// return null; //To change body of implemented methods use File | Settings | File Templates. -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } - -// @Override -// public PropagationDefinition getTxPropagationDefinition() { -// return PropagationDefinition.PROPAGATION_REQUIRED; -// } -// }); -// } - -// // @Test -// // public void shouldReadEventsCreatedEvents() throws URISyntaxException, SQLException { -// // List events = createEvents(7, "Hello, DiscWorld"); -// // final int[] counter = {0}; -// // URI uri = new URI("http://localhost:8080/feed/recent"); -// // AllMarkersInMemoryImpl allMarkersInMemoryImpl = new AllMarkersInMemoryImpl(); -// // allMarkersInMemoryImpl.put(uri, events.get(4).getTagUri().toString(), new URI("http://localhost:8080/feed/1")); -// // atomFeedClient = new AtomClientFactory().create(allMarkersInMemoryImpl, new AllFailedEventsInMemoryImpl()); -// // atomFeedClient.processEvents(uri, new EventWorker() { -// // @Override -// // public void process(Event event) { -// // counter[0] += 1; -// // } -// // }); -// // assertEquals(2, counter[0]); -// // } -// @Test -// public void shouldPublishFeedOfEvents() throws Exception, URISyntaxException { -// List events = transactionSupport.executeWithTransaction(new AFTransactionWork>() { -// @Override -// public List execute() { -// try { -// return createEvents(7, "Hello, DiscWorld"); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } + String contents =" \n" + + " Hello, DiscWorld6\n" + + " \n" + + " tag:atomfeed.ict4h.org:062df21f-62e7-405b-9c80-93d7e7a7b4f6\n" + + " 2013-07-02T03:16:30Z\n" + + " \n" + + " \n" + + " \n" + + " Hello, DiscWorld7\n" + + " \n" + + " tag:atomfeed.ict4h.org:4db7d280-8f64-4470-9d2b-180316034753\n" + + " 2013-07-02T03:16:30Z\n" + + " \n" + + " \n"; + + @Autowired + private EventResource eventResource; + + @Before + public void before() throws SQLException { + eventRecords = new OpenERPAllEventRecordsJdbcImpl(transactionSupport); + recordCreator = new DbEventRecordCreator(eventRecords); + } + + @After + public void after() throws SQLException { + transactionSupport.executeWithTransaction(new AFTransactionWork() { + @Override + public Object execute() { + try { + Connection connection = transactionSupport.getConnection(); + Statement statement = connection.createStatement(); + statement.execute("TRUNCATE public.event_records RESTART IDENTITY;"); + statement.close(); + return null; //To change body of implemented methods use File | Settings | File Templates. + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public PropagationDefinition getTxPropagationDefinition() { + return PropagationDefinition.PROPAGATION_REQUIRED; + } + }); + } +// @Test +// public void shouldReadEventsCreatedEvents() throws URISyntaxException, SQLException { +// List events = createEvents(7, "Hello, DiscWorld"); +// final int[] counter = {0}; +// URI uri = new URI("http://localhost:8080/feed/recent"); +// AllMarkersInMemoryImpl allMarkersInMemoryImpl = new AllMarkersInMemoryImpl(); +// allMarkersInMemoryImpl.put(uri, events.get(4).getTagUri().toString(), new URI("http://localhost:8080/feed/1")); +// atomFeedClient = new AtomClientFactory().create(allMarkersInMemoryImpl, new AllFailedEventsInMemoryImpl()); +// atomFeedClient.processEvents(uri, new EventWorker() { // @Override -// public PropagationDefinition getTxPropagationDefinition() { -// return PropagationDefinition.PROPAGATION_REQUIRED; +// public void process(Event event) { +// counter[0] += 1; // } // }); +// assertEquals(2, counter[0]); +// } + @Test + public void shouldPublishFeedOfEvents() throws Exception, URISyntaxException { + List events = transactionSupport.executeWithTransaction(new AFTransactionWork>() { + @Override + public List execute() { + try { + return createEvents(7, "Hello, DiscWorld"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public PropagationDefinition getTxPropagationDefinition() { + return PropagationDefinition.PROPAGATION_REQUIRED; + } + }); -// String responseAsString = null; -// MVCTestUtils.mockMvc(eventResource) -// .perform(get("/feed/product/recent")) -// .andExpect(compareContent()); -// } - -// private ResultMatcher compareContent() { -// return content().string(containsString("Hello, DiscWorld7")); -// } - -// private List createEvents(int numberOfEventsToCreate, String titleTemplate) throws URISyntaxException, SQLException { -// List records = new ArrayList(); -// int index = 1; -// do { -// records.add(createOneEvent(String.format("%s%s", titleTemplate, index), String.format("%s%s", "http://google.com?q=", index))); -// index++; -// } while (index <= numberOfEventsToCreate); -// return records; -// } - -// private EventRecord createOneEvent(String title, String url) throws URISyntaxException, SQLException { -// EventRecord eventRecord = recordCreator.create(UUID.randomUUID().toString(), title, url, "{\"category\": \"All products\", \"list_price\": 2, \"id\": 215, \"manufacturer\": \"cipla3\"}"); -// return eventRecord; -// } - - -// class OpenERPAllEventRecordsJdbcImpl extends AllEventRecordsJdbcImpl { -// public OpenERPAllEventRecordsJdbcImpl(JdbcConnectionProvider provider) { -// super(provider); -// } -// @Override -// public void add(EventRecord eventRecord) { -// Connection connection; -// PreparedStatement stmt = null; -// try { -// connection = transactionSupport.getConnection(); -// String insertSql = String.format("insert into %s (uuid, title, uri, object,category,timestamp) values (?, ?, ?, ?,?,?)", -// JdbcUtils.getTableName(Configuration.getInstance().getSchema(), "event_records")); -// stmt = connection.prepareStatement(insertSql); -// stmt.setString(1, eventRecord.getUuid()); -// stmt.setString(2, eventRecord.getTitle()); -// stmt.setString(3, eventRecord.getUri()); -// stmt.setString(4, eventRecord.getContents()); -// stmt.setString(5, eventRecord.getCategory()); -// stmt.setTimestamp(6, new Timestamp(eventRecord.getTimeStamp().getTime())); -// stmt.executeUpdate(); -// } catch (SQLException e) { -// throw new AtomFeedRuntimeException(e); -// } finally { -// closeAll(stmt, null); -// } -// } -// private void closeAll(PreparedStatement stmt, ResultSet rs) { -// try { -// if (rs != null) { -// rs.close(); -// } -// if (stmt != null) { -// stmt.close(); -// } -// } catch (SQLException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } - - -// } -// } + String responseAsString = null; + MVCTestUtils.mockMvc(eventResource) + .perform(get("/feed/product/recent")) + .andExpect(compareContent()); + } + + private ResultMatcher compareContent() { + return content().string(containsString("Hello, DiscWorld7")); + } + + private List createEvents(int numberOfEventsToCreate, String titleTemplate) throws URISyntaxException, SQLException { + List records = new ArrayList(); + int index = 1; + do { + records.add(createOneEvent(String.format("%s%s", titleTemplate, index), String.format("%s%s", "http://google.com?q=", index))); + index++; + } while (index <= numberOfEventsToCreate); + return records; + } + + private EventRecord createOneEvent(String title, String url) throws URISyntaxException, SQLException { + EventRecord eventRecord = recordCreator.create(UUID.randomUUID().toString(), title, url, "{\"category\": \"All products\", \"list_price\": 2, \"id\": 215, \"manufacturer\": \"cipla3\"}"); + return eventRecord; + } + + + class OpenERPAllEventRecordsJdbcImpl extends AllEventRecordsJdbcImpl { + public OpenERPAllEventRecordsJdbcImpl(JdbcConnectionProvider provider) { + super(provider); + } + @Override + public void add(EventRecord eventRecord) { + Connection connection; + PreparedStatement stmt = null; + try { + connection = transactionSupport.getConnection(); + String insertSql = String.format("insert into %s (uuid, title, uri, object,category,timestamp) values (?, ?, ?, ?,?,?)", + JdbcUtils.getTableName(Configuration.getInstance().getSchema(), "event_records")); + stmt = connection.prepareStatement(insertSql); + stmt.setString(1, eventRecord.getUuid()); + stmt.setString(2, eventRecord.getTitle()); + stmt.setString(3, eventRecord.getUri()); + stmt.setString(4, eventRecord.getContents()); + stmt.setString(5, eventRecord.getCategory()); + stmt.setTimestamp(6, new Timestamp(eventRecord.getTimeStamp().getTime())); + stmt.executeUpdate(); + } catch (SQLException e) { + throw new AtomFeedRuntimeException(e); + } finally { + closeAll(stmt, null); + } + } + private void closeAll(PreparedStatement stmt, ResultSet rs) { + try { + if (rs != null) { + rs.close(); + } + if (stmt != null) { + stmt.close(); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + } +} diff --git a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/utils/MVCTestUtils.java b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/utils/MVCTestUtils.java index 62f85442..758ea461 100644 --- a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/utils/MVCTestUtils.java +++ b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/utils/MVCTestUtils.java @@ -1,13 +1,13 @@ -// package org.bahmni.feed.openerp.utils; +package org.bahmni.feed.openerp.utils; -// import org.springframework.test.web.server.MockMvc; -// import org.springframework.test.web.server.setup.MockMvcBuilders; -// import org.springframework.test.web.server.setup.StandaloneMockMvcBuilder; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; -// public class MVCTestUtils { -// public static MockMvc mockMvc(Object controller) { -// StandaloneMockMvcBuilder mockMvcBuilder = MockMvcBuilders.standaloneSetup(controller); +public class MVCTestUtils { + public static MockMvc mockMvc(Object controller) { + StandaloneMockMvcBuilder mockMvcBuilder = MockMvcBuilders.standaloneSetup(controller); -// return mockMvcBuilder.build(); -// } -// } + return mockMvcBuilder.build(); + } +} diff --git a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPDrugServiceEventWorkerTest.java b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPDrugServiceEventWorkerTest.java index 4eb91356..814a6c26 100644 --- a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPDrugServiceEventWorkerTest.java +++ b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPDrugServiceEventWorkerTest.java @@ -1,3 +1,5 @@ +// TODO : Mockito Matchers Import Issue To Be Resolved + // package org.bahmni.feed.openerp.worker; // import org.bahmni.feed.openerp.OpenERPAtomFeedProperties; diff --git a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPSaleOrderEventWorkerIT.java b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPSaleOrderEventWorkerIT.java index edec806e..f07cca0d 100644 --- a/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPSaleOrderEventWorkerIT.java +++ b/openerp-atomfeed-service/src/test/java/org/bahmni/feed/openerp/worker/OpenERPSaleOrderEventWorkerIT.java @@ -1,3 +1,5 @@ +// TODO : Mockito Matchers Import Issue To Be Resolved + // package org.bahmni.feed.openerp.worker; // import org.bahmni.feed.openerp.ObjectMapperRepository; diff --git a/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerAccountServiceTest.java b/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerAccountServiceTest.java index 01a015ca..0062b829 100644 --- a/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerAccountServiceTest.java +++ b/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerAccountServiceTest.java @@ -1,3 +1,5 @@ +// TODO : Mockito Matchers Import Issue To Be Resolved + // package org.bahmni.openerp.web.service; // import org.bahmni.openerp.web.OpenERPException; diff --git a/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerServiceTest.java b/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerServiceTest.java index 83544fc2..09d30ea5 100644 --- a/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerServiceTest.java +++ b/openerp-client/src/test/java/org/bahmni/openerp/web/service/CustomerServiceTest.java @@ -1,3 +1,5 @@ +// TODO : Mockito Matchers Import Issue To Be Resolved + // package org.bahmni.openerp.web.service; // import org.bahmni.openerp.web.client.OpenERPClient; diff --git a/openerp-client/src/test/java/org/bahmni/openerp/web/service/OpenERPServiceTest.java b/openerp-client/src/test/java/org/bahmni/openerp/web/service/OpenERPServiceTest.java index 90d5b2b2..86f22921 100644 --- a/openerp-client/src/test/java/org/bahmni/openerp/web/service/OpenERPServiceTest.java +++ b/openerp-client/src/test/java/org/bahmni/openerp/web/service/OpenERPServiceTest.java @@ -1,3 +1,5 @@ +// TODO : Mockito Matchers Import Issue To Be Resolved + // package org.bahmni.openerp.web.service; // import org.bahmni.openerp.web.OpenERPException; diff --git a/openerp-client/src/test/java/org/bahmni/test/utils/MVCTestUtils.java b/openerp-client/src/test/java/org/bahmni/test/utils/MVCTestUtils.java index f5a9e22e..d2c8f727 100644 --- a/openerp-client/src/test/java/org/bahmni/test/utils/MVCTestUtils.java +++ b/openerp-client/src/test/java/org/bahmni/test/utils/MVCTestUtils.java @@ -1,13 +1,13 @@ -// package org.bahmni.test.utils; +package org.bahmni.test.utils; -// import org.springframework.test.web.server.MockMvc; -// import org.springframework.test.web.server.setup.MockMvcBuilders; -// import org.springframework.test.web.server.setup.StandaloneMockMvcBuilder; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; -// public class MVCTestUtils { -// public static MockMvc mockMvc(Object controller) { -// StandaloneMockMvcBuilder mockMvcBuilder = MockMvcBuilders.standaloneSetup(controller); +public class MVCTestUtils { + public static MockMvc mockMvc(Object controller) { + StandaloneMockMvcBuilder mockMvcBuilder = MockMvcBuilders.standaloneSetup(controller); -// return mockMvcBuilder.build(); -// } -// } + return mockMvcBuilder.build(); + } +}