Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/resources/moduleApplicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</property>
</bean>

<bean id="specialityService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<bean id="auditLogService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openmrs.User;
import org.openmrs.module.auditlog.util.DateUtil;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.Date;
Expand All @@ -17,6 +18,7 @@
import static org.junit.Assert.assertNull;
import static org.powermock.api.mockito.PowerMockito.when;

@PowerMockIgnore("javax.management.*")
@RunWith(PowerMockRunner.class)
public class AuditLogTest {
@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.openmrs.module.auditlog.model.AuditLog;
import org.openmrs.module.auditlog.util.DateUtil;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

Expand All @@ -31,6 +32,7 @@
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;

@PowerMockIgnore("javax.management.*")
@RunWith(PowerMockRunner.class)
@PrepareForTest(Context.class)
public class AuditLogServiceImplTest {
Expand Down Expand Up @@ -130,7 +132,7 @@ public void shouldCreateAuditLog() throws Exception {
AuditLogPayload log = new AuditLogPayload(patientUuid, "message", "eventType", "registration");
mockStatic(Context.class);
User user = new User();
user.setName("auditlogger");
user.setUsername("auditlogger");
when(Context.getAuthenticatedUser()).thenReturn(user);
when(Context.getPatientService()).thenReturn(patientService);
Patient patient = new Patient();
Expand All @@ -153,7 +155,7 @@ public void shouldCreateAuditLogWithParams() throws Exception {
String patientUuid = "patientUuid";
mockStatic(Context.class);
User user = new User();
user.setName("auditlogger");
user.setUsername("auditlogger");
when(Context.getAuthenticatedUser()).thenReturn(user);
when(Context.getPatientService()).thenReturn(patientService);
Patient patient = new Patient();
Expand All @@ -178,7 +180,7 @@ public void shouldIgnoreParamsIfIsEmptyWhenCreateAuditLogWithParams() throws Exc
String patientUuid = "patientUuid";
mockStatic(Context.class);
User user = new User();
user.setName("auditlogger");
user.setUsername("auditlogger");
when(Context.getAuthenticatedUser()).thenReturn(user);
when(Context.getPatientService()).thenReturn(patientService);
Patient patient = new Patient();
Expand Down
5 changes: 5 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
9 changes: 4 additions & 5 deletions omod/src/main/resources/webModuleApplicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@

<!-- Add here beans related to the web context -->


<!-- Annotation based controllers -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>


<context:component-scan base-package="org.openmrs.module.auditlog.web.controller" />
<context:component-scan base-package="org.openmrs.module.auditlog" />
<!-- <context:component-scan base-package="org.openmrs.module.auditlog" />-->



</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;
import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
Expand All @@ -22,10 +22,10 @@
public class BaseWebControllerTest extends BaseModuleWebContextSensitiveTest {

@Autowired
private AnnotationMethodHandlerAdapter handlerAdapter;
private RequestMappingHandlerAdapter handlerAdapter;

@Autowired
private List<DefaultAnnotationHandlerMapping> handlerMappings;
private List<RequestMappingHandlerMapping> handlerMappings;

private ObjectMapper objectMapper = new ObjectMapper();

Expand Down Expand Up @@ -124,7 +124,7 @@ public MockHttpServletResponse handle(HttpServletRequest request) throws Excepti
MockHttpServletResponse response = new MockHttpServletResponse();

HandlerExecutionChain handlerExecutionChain = null;
for (DefaultAnnotationHandlerMapping handlerMapping : handlerMappings) {
for (RequestMappingHandlerMapping handlerMapping : handlerMappings) {
handlerExecutionChain = handlerMapping.getHandler(request);
if (handlerExecutionChain != null) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openmrs.module.auditlog.util.DateUtil;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

Expand All @@ -29,6 +30,7 @@
import static org.mockito.MockitoAnnotations.initMocks;
import static org.powermock.api.mockito.PowerMockito.when;

@PowerMockIgnore("javax.management.*")
@PrepareForTest({Context.class})
@RunWith(PowerMockRunner.class)
public class AuditLogControllerTest {
Expand Down
24 changes: 6 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
</build>

<properties>
<openmrs.platform.version>2.1.0</openmrs.platform.version>
<openmrs.platform.version>2.5.0</openmrs.platform.version>
<!--test dependencies-->
<junitVersion>4.12</junitVersion>
<powerMockVersion>1.6.5</powerMockVersion>
<hamcrestVersion>1.3</hamcrestVersion>
<mockitoVersion>1.10.19</mockitoVersion>
<junitVersion>4.13</junitVersion>
<powerMockVersion>2.0.7</powerMockVersion>
<hamcrestVersion>2.2</hamcrestVersion>
<mockitoVersion>3.5.11</mockitoVersion>
<reportingModuleVersion>0.10.4</reportingModuleVersion>
<calculationModuleVersion>1.3-SNAPSHOT</calculationModuleVersion>
<serializationXstreamModuleVersion>0.2.12</serializationXstreamModuleVersion>
Expand All @@ -138,7 +138,7 @@

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powerMockVersion}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -208,18 +208,6 @@
<version>${hamcrestVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockitoVersion}</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
Expand Down