/*
 * Sonar ESQL Plugin
 * Copyright (C) 2013-2017 Thomas Pohl and EXXETA AG
 * http://www.exxeta.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.exxeta.iss.sonar.esql.api.tree;

import static com.exxeta.iss.sonar.esql.utils.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import org.junit.Test;

import com.exxeta.iss.sonar.esql.api.tree.Tree.Kind;
import com.exxeta.iss.sonar.esql.tree.impl.statement.MoveStatementTreeImpl;
import com.exxeta.iss.sonar.esql.utils.EsqlTreeModelTest;

public class MoveStatementTest extends EsqlTreeModelTest<MoveStatementTreeImpl>{
	@Test
	public void moveStatement(){
		
		assertThat(Kind.MOVE_STATEMENT)
		.matches("MOVE sourceCursor NEXTSIBLING;")
		.matches("MOVE cursor FIRSTCHILD TYPE Name NAME 'Field1';")
		.matches("MOVE cursor TO OutputRoot;");

	}
	
	@Test
	public void modelTest() throws Exception{
		MoveStatementTreeImpl tree = parse("MOVE cursor FIRSTCHILD TYPE Name NAME 'Field1';", Kind.MOVE_STATEMENT);
		assertNotNull(tree.moveKeyword());
		assertEquals(tree.moveKeyword().text(),"MOVE");
		assertNotNull(tree.target());
		assertEquals(tree.target().text(), "cursor");
		assertNull(tree.toKeyword());
		assertNull(tree.sourceFieldReference());
		assertNotNull(tree.qualifier());
		assertNotNull(tree.nameClauses());
		assertNotNull(tree.semi());
		assertEquals(tree.semi().text(), ";");
		
	}
	
}

@@ -1022,41 +1022,178 @@
 sql.
-tree.impl.statement.MoveStatement
+api.tree.lexical.SyntaxToken;%0Aimport com.exxeta.iss.sonar.esql.tree.impl.statement.MoveStatementTreeImpl;%0Aimport com.exxeta.iss.sonar.esql.tree.impl.statement.NameClauses
 Tree
@@ -2112,16 +2112,625 @@
 , %22;%22);%0A
+%09%09NameClausesTreeImpl nameClauses = tree.nameClauses();%0A%09%09assertNotNull(nameClauses.typeKeyword());%0A%09%09assertNotNull(nameClauses.typeExpression());%0A%09%09assertNull(nameClauses.namespaceKeyword());%0A%09%09assertNull(nameClauses.namespaceExpression());%0A%09%09assertNull(nameClauses.namespaceStar());%0A%09%09assertNotNull(nameClauses.nameKeyword());%0A%09%09assertNotNull(nameClauses.nameExpression());%0A%09%09%0A%09%09assertNull(nameClauses.identityKeyword());%0A%09%09assertNull(nameClauses.pathElement());%0A%09%09assertNull(nameClauses.repeatKeyword()); %0A%09%09assertNull(nameClauses.repeatTypeKeyword()); %0A%09%09assertNull(nameClauses.repeatNameKeyword()); %0A%0A%09%09%0A
 %09%09%0A%09%7D%0A%09%0A

move statement test