-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SYNCT-327:Enable disabling of Manual Sync to Parent and Manual Pull t…
…o Parent
- Loading branch information
1 parent
6b97207
commit 3dec202
Showing
4 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
.../java/org/openmrs/module/sync2/api/service/impl/atomfeed/LocalAtomfeedFeedReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.openmrs.module.sync2.api.service.impl.atomfeed; | ||
|
||
|
||
public class LocalAtomfeedFeedReaderTest { | ||
|
||
public void LocalAtomfeedFeedReader_shouldNotSyncIfPushIsDisabled() { | ||
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...java/org/openmrs/module/sync2/api/service/impl/atomfeed/ParentAtomfeedFeedReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.openmrs.module.sync2.api.service.impl.atomfeed; | ||
|
||
import static org.powermock.api.mockito.PowerMockito.doReturn; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.openmrs.module.sync2.api.exceptions.SyncException; | ||
import org.openmrs.module.sync2.api.service.SyncConfigurationService; | ||
import org.openmrs.module.sync2.api.service.impl.SyncConfigurationServiceImpl; | ||
import org.openmrs.module.sync2.client.reader.atomfeed.impl.ParentAtomfeedFeedReaderImpl; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ParentAtomfeedFeedReaderTest { | ||
|
||
@InjectMocks | ||
private ParentAtomfeedFeedReaderImpl parentAtomfeedFeedReaderImpl; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
@Mock | ||
private SyncConfigurationService sync2ConfigurationService; | ||
|
||
@Before | ||
public void setUp() throws SyncException { | ||
sync2ConfigurationService = new SyncConfigurationServiceImpl(); | ||
This comment has been minimized.
Sorry, something went wrong.
mhawila
Contributor
|
||
MockitoAnnotations.initMocks(this); | ||
doReturn("false").when(sync2ConfigurationService).getSyncConfiguration().getWhitelist().isEnabled(); | ||
} | ||
|
||
@Test | ||
public void ParentAtomfeedFeedReader_shouldNotSyncIfPullIsDisabled() throws SyncException { | ||
parentAtomfeedFeedReaderImpl.pullAndProcessAllFeeds(); | ||
} | ||
} |
First use the interface instead of the concrete implementation, therefore
private ParentAtomFeedReader parentAtomfeedReader
. Second this is the instance in which you want to inject mocks but it is not initialized anywhere. You could create this in the setUp() method or you could simply declare and initialize it here with new. I haven't checked the stack trace but I think this is where the NPE is coming from.