[teiid-commits] teiid SVN: r3388 - in branches/7.4.x: connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Aug 16 21:23:42 EDT 2011


Author: shawkins
Date: 2011-08-16 21:23:42 -0400 (Tue, 16 Aug 2011)
New Revision: 3388

Added:
   branches/7.4.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java
Modified:
   branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java
   branches/7.4.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
Log:
TEIID-1443 reapplying fix

Modified: branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java
===================================================================
--- branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java	2011-08-16 19:39:25 UTC (rev 3387)
+++ branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java	2011-08-17 01:23:42 UTC (rev 3388)
@@ -71,14 +71,18 @@
 
 	@Override
 	public void execute() throws TranslatorException {
-		if(getCommand().getProcedureName().endsWith("getUpdated")) {
+		String name = getCommand().getMetadataObject().getNameInSource();
+		if (name == null) {
+			name = getCommand().getProcedureName();
+		}
+		if("GetUpdated".equalsIgnoreCase(name)) { //$NON-NLS-1$
 			execution = new GetUpdatedExecutionImpl(this);
-			execution.execute(this);
-		}
-		else if(getCommand().getProcedureName().endsWith("getDeleted")) {
+		} else if("GetDeleted".equalsIgnoreCase(name)) { //$NON-NLS-1$
 			execution = new GetDeletedExecutionImpl(this);
-			execution.execute(this);
+		} else {
+			throw new AssertionError("Unknown procedure " + getCommand().getProcedureName() + " with name in source " + getCommand().getMetadataObject().getNameInSource()); //$NON-NLS-1$ //$NON-NLS-2$
 		}
+		execution.execute(this);
 	}
 
 	public void setCommand(Call command) {

Added: branches/7.4.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java
===================================================================
--- branches/7.4.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java	                        (rev 0)
+++ branches/7.4.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java	2011-08-17 01:23:42 UTC (rev 3388)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.salesforce.execution;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.cdk.api.TranslationUtility;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.execution.visitors.TestVisitors;
+
+ at SuppressWarnings("nls")
+public class TestProcedureExecution {
+	
+	private static TranslationUtility translationUtility = new TranslationUtility(TestVisitors.exampleSalesforce());
+
+	@Test public void testProcedureName() throws Exception {
+		Call command = (Call)translationUtility.parseCommand("exec getupdated('foo', {d '1970-01-01'}, {d '1990-01-01'})"); //$NON-NLS-1$
+		SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
+		UpdatedResult ur = new UpdatedResult();
+		ur.setIDs(Arrays.asList("1", "2"));
+		Mockito.stub(sfc.getUpdated(Mockito.eq("foo"), (XMLGregorianCalendar)Mockito.anyObject(), (XMLGregorianCalendar)Mockito.anyObject())).toReturn(ur);
+		ProcedureExecutionParentImpl pepi = new ProcedureExecutionParentImpl(command, sfc, Mockito.mock(RuntimeMetadata.class), Mockito.mock(ExecutionContext.class));
+		pepi.execute();
+		assertNotNull(pepi.next());
+		assertNotNull(pepi.next());
+		assertNull(pepi.next());
+		pepi.close();
+	}
+	
+}


Property changes on: branches/7.4.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java	2011-08-16 19:39:25 UTC (rev 3387)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java	2011-08-17 01:23:42 UTC (rev 3388)
@@ -1742,6 +1742,7 @@
     public static Procedure createStoredProcedure(String name, Schema model, List<ProcedureParameter> params) {
     	Procedure proc = new Procedure();
     	proc.setName(name);
+    	proc.setNameInSource(name);
     	if (params != null) {
     		int index = 1;
 	    	for (ProcedureParameter procedureParameter : params) {



More information about the teiid-commits mailing list