Coverage Report - org.mule.transport.jdbc.sqlstrategy.DefaultSqlStatementStrategyFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultSqlStatementStrategyFactory
0%
0/13
0%
0/12
4.5
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.jdbc.sqlstrategy;
 8  
 
 9  
 public class DefaultSqlStatementStrategyFactory implements SqlStatementStrategyFactory
 10  
 {
 11  
     protected SimpleUpdateSqlStatementStrategy simpleUpdateSQLStrategy;
 12  
     protected SelectSqlStatementStrategy selectSQLStrategy;
 13  
     protected CallableSqlStatementStrategy callableSQLStrategy;
 14  
 
 15  
     public DefaultSqlStatementStrategyFactory()
 16  0
     {
 17  0
         simpleUpdateSQLStrategy = new SimpleUpdateSqlStatementStrategy();
 18  0
         selectSQLStrategy = new SelectSqlStatementStrategy();
 19  0
         callableSQLStrategy = new CallableSqlStatementStrategy();
 20  0
     }
 21  
 
 22  
     public SqlStatementStrategy create(String sql, Object payload)
 23  
         throws Exception
 24  
     {
 25  0
         String sqlLowerCase = sql.toLowerCase();
 26  
 
 27  0
         if( sqlLowerCase.startsWith("insert") ||
 28  
             sqlLowerCase.startsWith("update") ||
 29  
             sqlLowerCase.startsWith("delete") ||
 30  
             sqlLowerCase.startsWith("merge"))
 31  
         {
 32  0
             return simpleUpdateSQLStrategy;
 33  
         }
 34  
 
 35  0
         if (sqlLowerCase.startsWith("select"))
 36  
         {
 37  0
             return selectSQLStrategy;
 38  
         }
 39  
 
 40  0
         if (sqlLowerCase.startsWith("call"))
 41  
         {
 42  0
             return callableSQLStrategy;
 43  
         }
 44  
 
 45  0
         throw new IllegalArgumentException("No SQL Strategy found for SQL statement: " + sql);
 46  
     }
 47  
 
 48  
 }