Source:
public void testRefreshWorkflow() { final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh"}); final long secondWorkflowCount = testingPostgres.runSelectStatement("select count(*) from workflow", new ScalarHandler<>()); Assert.assertTrue("should find non-zero number of workflows", secondWorkflowCount > 0); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh", "--entry", "github.com/DockstoreTestUser/dockstore-whalesay-wdl"}); testingPostgres.runUpdateStatement("update workflowversion set name = 'test'"); testingPostgres.runUpdateStatement("update workflowversion set reference = 'test'"); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh", "--entry", "github.com/DockstoreTestUser/dockstore-whalesay-wdl"}); final long updatedWorkflowVersionCount = testingPostgres.runSelectStatement("select count(*) from workflowversion", new ScalarHandler<>()); final long updatedWorkflowVersionName = testingPostgres.runSelectStatement("select count(*) from workflowversion where name='master'", new ScalarHandler<>()); Assert.assertTrue("there should be only one version", updatedWorkflowVersionCount == 1 && updatedWorkflowVersionName == 1); testingPostgres.runUpdateStatement("delete from token where tokensource = 'github.com'"); systemExit.checkAssertionAfterwards(() -> { final long thirdWorkflowCount = testingPostgres.runSelectStatement("select count(*) from workflow", new ScalarHandler<>()); Assert.assertTrue("there should be no change in count of workflows", secondWorkflowCount == thirdWorkflowCount); }); systemExit.expectSystemExit(); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh", "--entry", "github.com/DockstoreTestUser/dockstore-whalesay-wdl" }); }

Target:
public void testRefreshWorkflow() { final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh"}); final long secondWorkflowCount = testingPostgres.runSelectStatement("select count(*) from workflow", new ScalarHandler<>()); Assert.assertTrue("should find non-zero number of workflows", secondWorkflowCount > 0); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh", "--entry", SourceControl.GITHUB.toString() + "/DockstoreTestUser/dockstore-whalesay-wdl"}); testingPostgres.runUpdateStatement("update workflowversion set name = 'test'"); testingPostgres.runUpdateStatement("update workflowversion set reference = 'test'"); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh", "--entry", SourceControl.GITHUB.toString() + "/DockstoreTestUser/dockstore-whalesay-wdl"}); final long updatedWorkflowVersionCount = testingPostgres.runSelectStatement("select count(*) from workflowversion", new ScalarHandler<>()); final long updatedWorkflowVersionName = testingPostgres.runSelectStatement("select count(*) from workflowversion where name='master'", new ScalarHandler<>()); Assert.assertTrue("there should be only one version", updatedWorkflowVersionCount == 1 && updatedWorkflowVersionName == 1); testingPostgres.runUpdateStatement("delete from token where tokensource = 'github.com'"); systemExit.checkAssertionAfterwards(() -> { final long thirdWorkflowCount = testingPostgres.runSelectStatement("select count(*) from workflow", new ScalarHandler<>()); Assert.assertTrue("there should be no change in count of workflows", secondWorkflowCount == thirdWorkflowCount); }); systemExit.expectSystemExit(); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "workflow", "refresh", "--entry", SourceControl.GITHUB.toString() + "/DockstoreTestUser/dockstore-whalesay-wdl" }); }