// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
// 
// 	private static final long serialVersionUID = -5075723737186875253L;
// 
// 	private String[] path = null;
// 	private JsonContentType contentType = null;
// 	private String conversionPattern = null;
// 	/** enforce strict evaluation and require the field to be present */
// 	private boolean required = false;
// 	
// 	public JsonContentReference() {		
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType) {
// 		this(path, contentType, false);
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// 		this.path = path;
// 		this.contentType = contentType;
// 		this.required = required;
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// 		this.path = path;
// 		this.contentType = contentType;
// 		this.conversionPattern = conversionPattern;
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// 		this.path = path;
// 		this.contentType = contentType;
// 		this.conversionPattern = conversionPattern;
// 		this.required = required;
// 	}
// 
// 	public String[] getPath() {
// 		return path;
// 	}
// 
// 	public void setPath(String[] path) {
// 		this.path = path;
// 	}
// 
// 	public JsonContentType getContentType() {
// 		return contentType;
// 	}
// 
// 	public void setContentType(JsonContentType contentType) {
// 		this.contentType = contentType;
// 	}
// 
// 	public String getConversionPattern() {
// 		return conversionPattern;
// 	}
// 
// 	public void setConversionPattern(String conversionPattern) {
// 		this.conversionPattern = conversionPattern;
// 	}
// 
// 	public boolean isRequired() {
// 		return required;
// 	}
// 
// 	public void setRequired(boolean required) {
// 		this.required = required;
// 	}
// 	
// 	
// }
// 
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// 	STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN 
// }


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
 * Copyright 2016 Otto (GmbH & Co KG)
 *
 * 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.ottogroup.bi.streaming.operator.json.project;




/**
 * Test case for {@link JsonContentProjectionMapper}
 * @author mnxfst
 * @since Jan 27, 2016
 */
public class JsonContentProjectionMapperTest {

	/**
	 * Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
	 * being provided null as input
	 */
	@Test
	public void testConstructor_withNullInput() {
		Assert.assertTrue(new JsonContentProjectionMapper(null).getConfiguration().isEmpty());
	}

	/**
	 * Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
	 * being provided an empty list as input
	 */
	@Test
	public void testConstructor_withEmptyList() {
		Assert.assertTrue(new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).getConfiguration().isEmpty());
	}
	
	/**
	 * Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
	 * provided null as input
	 */
	@Test
	public void testMap_withNullInput() throws Exception {
		@SuppressWarnings("unchecked")
		List<ProjectionMapperConfiguration> cfg = Mockito.mock(List.class);
		Mockito.when(cfg.isEmpty()).thenReturn(true);
		Assert.assertNull(new JsonContentProjectionMapper(cfg).map(null));
		Mockito.verify(cfg, Mockito.times(1)).isEmpty();
	}
	
	/**
	 * Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
	 * provided a valid object but no configuration
	 */
	@Test
	public void testMap_withValidObjectEmptyConfiguration() throws Exception {
		Assert.assertEquals("{}", new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).
				map(new JSONObject("{\"key\":\"value\"}")).toString());
	}
	
	/**
	 * Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
	 * provided a valid object and valid configuration
	 */
	@Test
	public void testMap_withValidObjectValidConfiguration() throws Exception {
		String inputJson = "{\"test\":\"value\", \"sub\":{\"key\":\"another-value\"}}";
		List<ProjectionMapperConfiguration> cfg = new ArrayList<>();
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
// 
// 	private static final long serialVersionUID = -5075723737186875253L;
// 
// 	private String[] path = null;
// 	private JsonContentType contentType = null;
// 	private String conversionPattern = null;
// 	/** enforce strict evaluation and require the field to be present */
// 	private boolean required = false;
// 	
// 	public JsonContentReference() {		
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType) {
// 		this(path, contentType, false);
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// 		this.path = path;
// 		this.contentType = contentType;
// 		this.required = required;
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// 		this.path = path;
// 		this.contentType = contentType;
// 		this.conversionPattern = conversionPattern;
// 	}
// 	
// 	public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// 		this.path = path;
// 		this.contentType = contentType;
// 		this.conversionPattern = conversionPattern;
// 		this.required = required;
// 	}
// 
// 	public String[] getPath() {
// 		return path;
// 	}
// 
// 	public void setPath(String[] path) {
// 		this.path = path;
// 	}
// 
// 	public JsonContentType getContentType() {
// 		return contentType;
// 	}
// 
// 	public void setContentType(JsonContentType contentType) {
// 		this.contentType = contentType;
// 	}
// 
// 	public String getConversionPattern() {
// 		return conversionPattern;
// 	}
// 
// 	public void setConversionPattern(String conversionPattern) {
// 		this.conversionPattern = conversionPattern;
// 	}
// 
// 	public boolean isRequired() {
// 		return required;
// 	}
// 
// 	public void setRequired(boolean required) {
// 		this.required = required;
// 	}
// 	
// 	
// }
// 
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// 	STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN 
// }


// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/project/JsonContentProjectionMapperTest.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;

/**
 * Copyright 2016 Otto (GmbH & Co KG)
 *
 * 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.ottogroup.bi.streaming.operator.json.project;




/**
 * Test case for {@link JsonContentProjectionMapper}
 * @author mnxfst
 * @since Jan 27, 2016
 */
public class JsonContentProjectionMapperTest {

	/**
	 * Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
	 * being provided null as input
	 */
	@Test
	public void testConstructor_withNullInput() {
		Assert.assertTrue(new JsonContentProjectionMapper(null).getConfiguration().isEmpty());
	}

	/**
	 * Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
	 * being provided an empty list as input
	 */
	@Test
	public void testConstructor_withEmptyList() {
		Assert.assertTrue(new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).getConfiguration().isEmpty());
	}
	
	/**
	 * Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
	 * provided null as input
	 */
	@Test
	public void testMap_withNullInput() throws Exception {
		@SuppressWarnings("unchecked")
		List<ProjectionMapperConfiguration> cfg = Mockito.mock(List.class);
		Mockito.when(cfg.isEmpty()).thenReturn(true);
		Assert.assertNull(new JsonContentProjectionMapper(cfg).map(null));
		Mockito.verify(cfg, Mockito.times(1)).isEmpty();
	}
	
	/**
	 * Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
	 * provided a valid object but no configuration
	 */
	@Test
	public void testMap_withValidObjectEmptyConfiguration() throws Exception {
		Assert.assertEquals("{}", new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).
				map(new JSONObject("{\"key\":\"value\"}")).toString());
	}
	
	/**
	 * Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
	 * provided a valid object and valid configuration
	 */
	@Test
	public void testMap_withValidObjectValidConfiguration() throws Exception {
		String inputJson = "{\"test\":\"value\", \"sub\":{\"key\":\"another-value\"}}";
		List<ProjectionMapperConfiguration> cfg = new ArrayList<>();
		cfg.add(new ProjectionMapperConfiguration(new JsonContentReference(new String[]{"sub","key"}, JsonContentType.STRING, false), 