use of mockit.VerificationsInOrder in project streamline by hortonworks.
the class TopologyTestRunnerTest method runTest_withTestCaseId.
@Test
public void runTest_withTestCaseId() throws Exception {
Topology topology = createSimpleDAGInjectedTestTopology();
Long topologyId = topology.getId();
Long testCaseId = 1L;
TopologyTestRunCase testCase = new TopologyTestRunCase();
testCase.setId(testCaseId);
testCase.setTopologyId(topology.getId());
testCase.setName("testcase1");
testCase.setTimestamp(System.currentTimeMillis());
setTopologyCurrentVersionExpectation(topology);
setTopologyTestRunCaseExpectations(topology, testCase);
setTopologyTestRunCaseSinkNotFoundExpectations(topology, testCase);
setTopologyTestRunHistoryExpectations();
setSucceedTopologyActionsExpectations();
long sourceCount = topology.getTopologyDag().getOutputComponents().stream().filter(c -> c instanceof StreamlineSource).count();
long sinkCount = topology.getTopologyDag().getInputComponents().stream().filter(c -> c instanceof StreamlineSink).count();
TopologyTestRunHistory resultHistory = topologyTestRunner.runTest(topologyActions, topology, testCase, null);
waitForTopologyTestRunToFinish(resultHistory);
assertNotNull(resultHistory);
assertTrue(resultHistory.getFinished());
assertTrue(resultHistory.getSuccess());
new VerificationsInOrder() {
{
catalogService.getTopologyTestRunCaseSourceBySourceId(testCaseId, anyLong);
times = (int) sourceCount;
catalogService.getTopologyTestRunCaseSinkBySinkId(testCaseId, anyLong);
times = (int) sinkCount;
TopologyTestRunHistory runHistory;
// some fields are already modified after calling the method, so don't need to capture it
catalogService.addTopologyTestRunHistory(withInstanceOf(TopologyTestRunHistory.class));
times = 1;
catalogService.addOrUpdateTopologyTestRunHistory(anyLong, runHistory = withCapture());
times = 1;
assertEquals(topology.getId(), runHistory.getTopologyId());
assertEquals(topology.getVersionId(), runHistory.getVersionId());
assertTrue(runHistory.getFinished());
assertTrue(runHistory.getSuccess());
assertNotNull(runHistory.getStartTime());
assertNotNull(runHistory.getFinishTime());
assertTrue(runHistory.getFinishTime() - runHistory.getStartTime() >= 0);
assertTrue(isEmptyJson(runHistory.getExpectedOutputRecords()));
assertTrue(isNotEmptyJson(runHistory.getActualOutputRecords()));
assertFalse(runHistory.getMatched());
}
};
}
use of mockit.VerificationsInOrder in project streamline by hortonworks.
the class TopologyTestRunnerTest method runTest_withMatchedExpectedOutputRecords.
@Test
public void runTest_withMatchedExpectedOutputRecords() throws Exception {
Topology topology = createSimpleDAGInjectedTestTopology();
Long testCaseId = 1L;
TopologyTestRunCase testCase = new TopologyTestRunCase();
testCase.setId(testCaseId);
testCase.setTopologyId(topology.getId());
testCase.setName("testcase1");
testCase.setTimestamp(System.currentTimeMillis());
setTopologyCurrentVersionExpectation(topology);
setTopologyTestRunCaseExpectations(topology, testCase);
setTopologyTestRunCaseSinkExpectations(topology, testCase);
setTopologyTestRunHistoryExpectations();
setSucceedTopologyActionsExpectations();
TopologyTestRunHistory resultHistory = topologyTestRunner.runTest(topologyActions, topology, testCase, null);
assertNotNull(resultHistory);
waitForTopologyTestRunToFinish(resultHistory);
new VerificationsInOrder() {
{
TopologyTestRunHistory runHistory;
// some fields are already modified after calling the method, so don't need to capture it
catalogService.addTopologyTestRunHistory(withInstanceOf(TopologyTestRunHistory.class));
times = 1;
catalogService.addOrUpdateTopologyTestRunHistory(anyLong, runHistory = withCapture());
times = 1;
assertEquals(topology.getId(), runHistory.getTopologyId());
assertEquals(topology.getVersionId(), runHistory.getVersionId());
assertTrue(runHistory.getFinished());
assertTrue(runHistory.getSuccess());
assertNotNull(runHistory.getStartTime());
assertNotNull(runHistory.getFinishTime());
assertTrue(runHistory.getFinishTime() - runHistory.getStartTime() >= 0);
assertTrue(isNotEmptyJson(runHistory.getExpectedOutputRecords()));
assertTrue(isNotEmptyJson(runHistory.getActualOutputRecords()));
assertTrue(runHistory.getMatched());
}
};
}
use of mockit.VerificationsInOrder in project registry by hortonworks.
the class ManagedTransactionTest method testCaseCommitTransactionThrowsException.
@Test
public void testCaseCommitTransactionThrowsException() {
final Exception commitException = new Exception("Commit exception");
new Expectations() {
{
mockedTransactionManager.commitTransaction();
result = commitException;
}
};
try {
managedTransaction.executeConsumer(this::callHelperWithReturn);
Assert.fail("It should propagate Exception");
} catch (Exception e) {
Assert.assertEquals(commitException, e);
Assert.assertTrue(testHelper.isCalled());
new VerificationsInOrder() {
{
mockedTransactionManager.beginTransaction(transactionIsolation);
times = 1;
mockedTransactionManager.commitTransaction();
times = 1;
mockedTransactionManager.rollbackTransaction();
times = 1;
}
};
}
}
use of mockit.VerificationsInOrder in project docker-maven-plugin by fabric8io.
the class ComposeUtilsTest method resolveComposeFileWithRelativeComposeFileAndAbsoluteBaseDir.
@Test
public void resolveComposeFileWithRelativeComposeFileAndAbsoluteBaseDir() throws Exception {
// relative/path/to/docker-compose.yaml
String relComposeFile = join(SEP, "relative", "path", "to", "docker-compose.yaml");
final String absMavenProjectDir = createTmpFile(className).getAbsolutePath();
new Expectations() {
{
project.getBasedir();
result = new File(absMavenProjectDir);
}
};
assertEquals(new File(ABS_BASEDIR, relComposeFile), ComposeUtils.resolveComposeFileAbsolutely(ABS_BASEDIR, relComposeFile, project));
new VerificationsInOrder() {
{
project.getBasedir();
}
};
}
use of mockit.VerificationsInOrder in project docker-maven-plugin by fabric8io.
the class ComposeUtilsTest method resolveComposeFileWithRelativeComposeFileAndRelativeBaseDir.
@Test
public void resolveComposeFileWithRelativeComposeFileAndRelativeBaseDir() throws Exception {
// relative/path/to/docker-compose.yaml
String relComposeFile = join(SEP, "relative", "path", "to", "docker-compose.yaml");
String relBaseDir = "basedir" + SEP;
final String absMavenProjectDir = createTmpFile(className).getAbsolutePath();
new Expectations() {
{
project.getBasedir();
result = new File(absMavenProjectDir);
}
};
assertEquals(new File(new File(absMavenProjectDir, relBaseDir), relComposeFile), ComposeUtils.resolveComposeFileAbsolutely(relBaseDir, relComposeFile, project));
new VerificationsInOrder() {
{
project.getBasedir();
}
};
}
Aggregations