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
13 changes: 10 additions & 3 deletions api/src/main/java/org/openmrs/aop/LoggingAdvice.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
Expand Down Expand Up @@ -44,7 +46,8 @@ public class LoggingAdvice implements MethodInterceptor {
* log4j2.xml configuration
*/
private final Logger log = LoggerFactory.getLogger(OpenmrsConstants.LOG_CLASS_DEFAULT);

private static final Marker PERFORMANCE_MARKER = MarkerFactory.getMarker("performance");

/**
* This method prints out trace statements for getters and debug statements for everything else
* ("setters"). If debugging is turned on, execution time for each method is printed as well.
Expand Down Expand Up @@ -156,10 +159,14 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
// print the string as either trace or debug
if (logGetter) {
log.trace(output.toString());
} else if (logSetter) {
log.debug(output.toString());
}
} else if (logSetter) {
if (log.isDebugEnabled()) {
log.debug(PERFORMANCE_MARKER, output.toString());
}
}

}
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.openmrs.api.db.hibernate;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;
import org.openmrs.Form;
import org.openmrs.api.db.FormDAO;
import org.openmrs.test.BaseContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;

public class HibernateFormDAOTest extends BaseContextSensitiveTest {

@Autowired
private FormDAO formDAO;

@Test
public void getAllForms_shouldExcludeRetiredFormsWhenIncludeRetiredIsFalse() {
// when
List<Form> forms = formDAO.getAllForms(false);

// then
assertNotNull(forms);
assertFalse(forms.isEmpty());

for (Form form : forms) {
assertFalse(form.getRetired());
}
}
}