-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
163 additions
and
19 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
59 changes: 59 additions & 0 deletions
59
lib/vdyp-common/src/test/java/ca/bc/gov/nrs/vdyp/application/ProcessorTest.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,59 @@ | ||
package ca.bc.gov.nrs.vdyp.application; | ||
|
||
import java.io.IOException; | ||
import java.util.EnumSet; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
|
||
import org.easymock.EasyMock; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ca.bc.gov.nrs.vdyp.io.FileResolver; | ||
import ca.bc.gov.nrs.vdyp.io.parse.common.ResourceParseException; | ||
import ca.bc.gov.nrs.vdyp.io.parse.control.BaseControlParser; | ||
import ca.bc.gov.nrs.vdyp.test.MockFileResolver; | ||
import ca.bc.gov.nrs.vdyp.test.TestUtils; | ||
|
||
class ProcessorTest { | ||
|
||
@Test | ||
void test() throws IOException, ResourceParseException, ProcessingException { | ||
|
||
Processor unit = EasyMock.partialMockBuilder(Processor.class).addMockedMethod("getControlFileParser") | ||
.addMockedMethod("process", Set.class, Map.class, Optional.class, Predicate.class).createStrictMock(); | ||
|
||
BaseControlParser controlParser = EasyMock.createMock(BaseControlParser.class); | ||
|
||
var inputResolver = new MockFileResolver("input"); | ||
var outputResolver = new MockFileResolver("output"); | ||
|
||
var is = TestUtils.makeInputStream("TEST"); | ||
|
||
inputResolver.addStream("test.ctr", is); | ||
|
||
var mockMap = new HashMap<String, Object>(); | ||
|
||
EasyMock.expect( | ||
controlParser | ||
.parse(EasyMock.same(is), EasyMock.anyObject(FileResolver.class), EasyMock.anyObject(Map.class)) | ||
).andStubReturn(mockMap); | ||
|
||
EasyMock.expect(unit.getControlFileParser()).andStubReturn(controlParser); | ||
|
||
unit.process( | ||
EasyMock.eq(EnumSet.allOf(Pass.class)), EasyMock.same(mockMap), EasyMock.anyObject(Optional.class), | ||
EasyMock.anyObject(Predicate.class) | ||
); | ||
EasyMock.expectLastCall(); | ||
|
||
EasyMock.replay(unit, controlParser); | ||
|
||
unit.run(inputResolver, outputResolver, List.of("test.ctr"), EnumSet.allOf(Pass.class)); | ||
|
||
EasyMock.verify(unit, controlParser); | ||
} | ||
} |
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