/*
 * Copyright 2009-2015 DigitalGlobe, Inc.
 *
 * 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 org.mrgeo.mapalgebra;

import org.junit.*;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.mrgeo.data.ProviderProperties;
import org.mrgeo.junit.UnitTest;
import org.mrgeo.test.LocalRunnerTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

@Ignore
public class BuildPyramidMapOpTest extends LocalRunnerTest
{
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(BuildPyramidMapOpTest.class);

@Rule
public TestName testname = new TestName();

@BeforeClass
public static void init() throws IOException
{
}

@Before
public void setup() throws IOException
{
}

@Test
@Category(UnitTest.class)
public void testTooFewArgs() throws Exception
{
  String exp = "BuildPyramid()";
  Assert.assertFalse(MapAlgebra.validate(exp, ProviderProperties.fromDelimitedString("")));
}

@Test
@Category(UnitTest.class)
public void testTooManyArgs() throws Exception
{
  String exp = String.format("BuildPyramid([%s], \"mean\", \"bogus\")", "foo");
  Assert.assertFalse(MapAlgebra.validate(exp, ProviderProperties.fromDelimitedString("")));
}

@Test
@Category(UnitTest.class)
public void testBadInput() throws Exception
{
  String exp =
      "BuildPyramid(InlineCsv(\"NAME,GEOMETRY\",\"'Place1','POINT(69.1 34.5)';'Place2','POINT(69.25 34.55)'\"), \"mean\")";
  Assert.assertFalse(MapAlgebra.validate(exp, ProviderProperties.fromDelimitedString("")));
}
}

@@ -800,24 +800,76 @@
 t.UnitTest;%0A
+import org.mrgeo.mapalgebra.parser.ParserException;%0A
 import org.m
@@ -1330,32 +1330,66 @@
 ption%0A%7B%0A%7D%0A%0A@Test
+(expected = ParserException.class)
 %0A@Category(UnitT
@@ -1482,35 +1482,16 @@
 d()%22;%0A  
-Assert.assertFalse(
 MapAlgeb
@@ -1493,32 +1493,46 @@
 Algebra.validate
+WithExceptions
 (exp, ProviderPr
@@ -1556,33 +1556,32 @@
 mitedString(%22%22))
-)
 ;%0A%7D%0A%0A@Test%0A@Cate
@@ -1566,32 +1566,66 @@
 g(%22%22));%0A%7D%0A%0A@Test
+(expected = ParserException.class)
 %0A@Category(UnitT
@@ -1766,35 +1766,16 @@
 oo%22);%0A  
-Assert.assertFalse(
 MapAlgeb
@@ -1777,32 +1777,46 @@
 Algebra.validate
+WithExceptions
 (exp, ProviderPr
@@ -1844,25 +1844,24 @@
 dString(%22%22))
-)
 ;%0A%7D%0A%0A@Test%0A@
@@ -1858,16 +1858,50 @@
 %7D%0A%0A@Test
+(expected = ParserException.class)
 %0A@Catego
@@ -2110,27 +2110,8 @@
 ;%0A  
-Assert.assertFalse(
 MapA
@@ -2125,16 +2125,30 @@
 validate
+WithExceptions
 (exp, Pr
@@ -2188,15 +2188,14 @@
 ing(%22%22))
-)
 ;%0A%7D%0A%7D%0A

Tweak tests