Skip to content

Commit

Permalink
fix GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
binduak committed Oct 6, 2022
1 parent 2ff2eb0 commit 4c86fb1
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.openmrs.module.bahmniemrapi.encountertransaction.advice;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openmrs.module.bahmniemrapi.encountertransaction.contract.BahmniEncounterTransaction;
import org.openmrs.util.LocaleUtility;
import org.openmrs.util.OpenmrsUtil;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
Expand All @@ -12,15 +14,23 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;

import org.apache.commons.lang.StringUtils;

import java.util.Locale;

@RunWith(PowerMockRunner.class)
@PrepareForTest(OpenmrsUtil.class)
public class BahmniEncounterTransactionUpdateAdviceTest {
private static String DEFAULT_ENCOUNTER_UUID = "defaultEncounterUuid";

@Before
public void setUp() throws Exception {
mockStatic(OpenmrsUtil.class);
}

@Test
public void shouldExecuteObsValueCalculatorFromApplicationDataDirectory() throws Throwable {
PowerMockito.mockStatic(OpenmrsUtil.class);
Expand All @@ -40,13 +50,13 @@ public void shouldLoadpplicationDataDirectoryPath() throws Throwable {
path = StringUtils.chop(path);
System.out.println(path);
when(OpenmrsUtil.getApplicationDataDirectory()).thenReturn(path);

BahmniEncounterTransaction bahmniEncounterTransaction = new BahmniEncounterTransaction();
new BahmniEncounterTransactionUpdateAdvice().before(null, new BahmniEncounterTransaction[]{bahmniEncounterTransaction}, null);

assertThat(bahmniEncounterTransaction.getEncounterUuid(), is(equalTo(DEFAULT_ENCOUNTER_UUID)));
}

@Test
public void shouldNotFailIfobscalculatorDirectoryDoesNotExist() throws Throwable {
PowerMockito.mockStatic(OpenmrsUtil.class);
Expand All @@ -57,4 +67,4 @@ public void shouldNotFailIfobscalculatorDirectoryDoesNotExist() throws Throwable

assertThat(bahmniEncounterTransaction.getEncounterUuid(), is(not(equalTo(DEFAULT_ENCOUNTER_UUID))));
}
}
}

0 comments on commit 4c86fb1

Please sign in to comment.