List of usage examples for org.apache.commons.dbutils.handlers ScalarHandler ScalarHandler
public ScalarHandler()
From source file:io.dockstore.client.cli.GeneralET.java
/** * Change toolname of a container//from w w w.j ava 2 s . c om */ @Test public void testChangeToolname() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file2.txt"), "tool", "manual_publish", "--registry", Registry.QUAY_IO.toString(), "--namespace", "dockstoretestuser2", "--name", "quayandgithubalternate", "--git-url", "git@github.com:dockstoretestuser2/quayandgithubalternate.git", "--git-reference", "master", "--toolname", "alternate", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", "--script" }); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file2.txt"), "tool", ToolClient.UPDATE_TOOL, "--entry", "quay.io/dockstoretestuser2/quayandgithubalternate/alternate", "--toolname", "alternate", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where path = 'quay.io/dockstoretestuser2/quayandgithubalternate' and toolname = 'alternate'", new ScalarHandler<>()); Assert.assertTrue("there should only be one instance of the container with the toolname set to alternate", count == 1); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file2.txt"), "tool", ToolClient.UPDATE_TOOL, "--entry", "quay.io/dockstoretestuser2/quayandgithubalternate", "--toolname", "toolnameTest", "--script" }); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where path = 'quay.io/dockstoretestuser2/quayandgithubalternate' and toolname = 'toolnameTest'", new ScalarHandler<>()); Assert.assertTrue( "there should only be one instance of the container with the toolname set to toolnameTest", count2 == 1); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Checks that you can manually publish and unpublish a Quay/Bitbucket entry with an alternate structure, if the CWL and Dockerfile paths are defined properly *//* w w w .j a v a2 s. co m*/ @Test public void testQuayBitbucketManualPublishAndUnpublishAlternateStructure() { // Manual Publish Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.QUAY_IO.toString(), "--namespace", "dockstoretestuser", "--name", "quayandbitbucketalternate", "--git-url", "git@bitbucket.org:DockstoreTestUser/quayandbitbucketalternate.git", "--git-reference", "master", "--toolname", "alternate", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entries, there are " + count, count == 1); // Unpublish Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "quay.io/dockstoretestuser/quayandbitbucketalternate/alternate", "--script" }); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 0 entries, there are " + count2, count2 == 0); }
From source file:io.dockstore.client.cli.GeneralET.java
/** * Tests that a user can only add Quay containers that they own directly or through an organization *//*from w ww . j a v a2 s .c o m*/ @Test public void testUserPrivilege() { final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); // Repo user has access to Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file2.txt"), "tool", "manual_publish", "--registry", Registry.QUAY_IO.toString(), "--namespace", "dockstoretestuser2", "--name", "quayandgithub", "--git-url", "git@github.com:dockstoretestuser2/quayandgithubalternate.git", "--git-reference", "master", "--toolname", "testTool", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", "--script" }); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where path = 'quay.io/dockstoretestuser2/quayandgithub' and toolname = 'testTool'", new ScalarHandler<>()); Assert.assertTrue("the container should exist", count == 1); // Repo user is part of org Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file2.txt"), "tool", "manual_publish", "--registry", Registry.QUAY_IO.toString(), "--namespace", "dockstore2", "--name", "testrepo2", "--git-url", "git@github.com:dockstoretestuser2/quayandgithub.git", "--git-reference", "master", "--toolname", "testOrg", "--cwl-path", "/Dockstore.cwl", "--dockerfile-path", "/Dockerfile", "--script" }); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where path = 'quay.io/dockstore2/testrepo2' and toolname = 'testOrg'", new ScalarHandler<>()); Assert.assertTrue("the container should exist", count2 == 1); // Repo user doesn't own systemExit.expectSystemExitWithStatus(Client.API_ERROR); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file2.txt"), "tool", "manual_publish", "--registry", Registry.QUAY_IO.toString(), "--namespace", "dockstoretestuser", "--name", "testrepo", "--git-url", "git@github.com:dockstoretestuser/quayandgithub.git", "--git-reference", "master", "--toolname", "testTool", "--cwl-path", "/Dockstore.cwl", "--dockerfile-path", "/Dockerfile", "--script" }); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Tests manual registration and unpublishing of a Dockerhub/Github entry *///from www .ja va2 s. c o m @Test public void testDockerhubGithubManualRegistration() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandgithub", "--git-url", "git@github.com:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entries", count == 1); // Unpublish Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandgithub/regular", "--script" }); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 0 entries", count2 == 0); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Will test manually publishing and unpublishing a Dockerhub/Github entry with an alternate structure *///from w w w. java 2 s .c o m @Test public void testDockerhubGithubAlternateStructure() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandgithub", "--git-url", "git@github.com:DockstoreTestUser/dockstore-whalesay-alternate.git", "--git-reference", "master", "--toolname", "alternate", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and ispublished='t' and validtrigger='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count == 1); // Unpublish Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandgithub/alternate", "--script" }); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and ispublished='f' and validtrigger='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count2 == 1); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Checks that you can manually publish and unpublish a Dockerhub/Github duplicate if different toolnames are set (but same Path) *//*from w w w .ja v a 2 s .c o m*/ @Test public void testDockerhubGithubManualRegistrationDuplicates() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandgithub", "--git-url", "git@github.com:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count == 1); // Add duplicate entry with different toolname Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandgithub", "--git-url", "git@github.com:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular2", "--script" }); // Unpublish the duplicate entrys final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname like 'regular%' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 2 entries", count2 == 2); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandgithub/regular", "--script" }); final long count3 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular2' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count3 == 1); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandgithub/regular2", "--script" }); final long count4 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname like 'regular%' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 0 entries", count4 == 0); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Tests manual registration and unpublishing of a Dockerhub/Bitbucket entry *//*from w ww . j a va 2 s . c o m*/ @Test public void testDockerhubBitbucketManualRegistration() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entries, there are " + count, count == 1); // Unpublish Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular", "--script" }); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 0 entries, there are " + count2, count2 == 0); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Will test manually publishing and unpublishing a Dockerhub/Bitbucket entry with an alternate structure */// w w w .j a v a2 s .c om @Test public void testDockerhubBitbucketAlternateStructure() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/quayandbitbucketalternate.git", "--git-reference", "master", "--toolname", "alternate", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count == 1); final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and validtrigger='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 valid entry", count2 == 1); // Unpublish Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/alternate", "--script" }); final long count3 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and ispublished='f'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count3 == 1); final long count4 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'alternate' and validtrigger='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 valid entry", count4 == 1); }
From source file:io.dockstore.client.cli.BasicET.java
/** * Checks that you can manually publish and unpublish a Dockerhub/Github duplicate if different toolnames are set (but same Path) *//*from w w w .j a va2s.com*/ @Test public void testDockerhubBitbucketManualRegistrationDuplicates() { Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular", "--script" }); final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count == 1); // Add duplicate entry with different toolname Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "manual_publish", "--registry", Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular2", "--script" }); // Unpublish the duplicate entrys final long count2 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname like 'regular%' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 2 entries", count2 == 2); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular", "--script" }); final long count3 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname = 'regular2' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 1 entry", count3 == 1); Client.main(new String[] { "--config", ResourceHelpers.resourceFilePath("config_file.txt"), "tool", "publish", "--unpub", "--entry", "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular2", "--script" }); final long count4 = testingPostgres.runSelectStatement( "select count(*) from tool where toolname like 'regular%' and ispublished='t'", new ScalarHandler<>()); Assert.assertTrue("there should be 0 entries", count4 == 0); }
From source file:jdao.JDAO.java
public static <T> T insertWithPK(int dbType, Connection conn, QueryRunner ds, String table, Map cols, boolean onDuplicateKeyUpdate, Collection updateFields, Class<T> clazz) throws Exception { if (onDuplicateKeyUpdate && (dbType != JDAO.DB_TYPE_MYSQL) && (dbType != JDAO.DB_TYPE_CRATE)) { throw new IllegalArgumentException("DB TYPE NOT MYSQL"); }//from www .j av a 2s. c o m Vector parm = new Vector(); StringBuilder qq = new StringBuilder(); qq.append("INSERT INTO " + table + " ( "); boolean op = true; for (Object kv : cols.entrySet()) { parm.add(((Map.Entry) kv).getValue()); if (!op) { qq.append(","); } qq.append(((Map.Entry) kv).getKey()); op = false; } qq.append(" ) VALUES ("); op = true; for (Object v : parm) { if (!op) { qq.append(","); } qq.append("?"); op = false; } qq.append(" ) "); if (onDuplicateKeyUpdate) { Map um = new HashMap(); for (Object o : updateFields) { um.put(o, cols.get(o)); } String setuqq = buildSet(dbType, parm, um); qq.append(" ON DUPLICATE KEY UPDATE "); qq.append(setuqq); } if (conn == null) { return ds.insert(qq.toString(), new ScalarHandler<T>(), parm.toArray()); } return ds.insert(conn, qq.toString(), new ScalarHandler<T>(), parm.toArray()); }