package uk.co.jemos.podam.test.unit;

import org.junit.Assert;
import org.junit.Test;

import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;
import uk.co.jemos.podam.test.dto.ReadOnlyComplexTypesPojo;
import uk.co.jemos.podam.test.dto.ReadOnlyGenericComplexTypesPojo;
import uk.co.jemos.podam.test.utils.PodamTestUtils;

/**
 * @author daivanov
 *
 */
public class ReadOnlyComplexTypesTest {

	private static final PodamFactory factory = new PodamFactoryImpl();

	@Test
	public void testReadOnlyComplexTypesPojoInstantiation() {
		ReadOnlyComplexTypesPojo pojo = factory.manufacturePojo(ReadOnlyComplexTypesPojo.class);
		Assert.assertNotNull("Manufacturing failed", pojo);
		Assert.assertNotNull("List should be present", pojo.getList());
		Assert.assertNotNull("Map should be present", pojo.getMap());
		Assert.assertNotNull("Complex element should be present", pojo.getValue());
		PodamTestUtils.assertListElementsType(pojo.getList(), Integer.class);
		PodamTestUtils.assertMapElementsType(pojo.getMap(), Long.class, String.class);
		Assert.assertNotNull("Complex element should not be empty",
				pojo.getValue().getValue());
	}

	@Test
	public void testReadOnlyGenericComplexTypesPojoInstantiation() {
		ReadOnlyGenericComplexTypesPojo<?, ?, ?> pojo
				= factory.manufacturePojo(ReadOnlyGenericComplexTypesPojo.class,
						Character.class, Long.class, Integer.class);
		Assert.assertNotNull("Manufacturing failed", pojo);
		Assert.assertNotNull("List should be present", pojo.getList());
		Assert.assertNotNull("Map should be present", pojo.getMap());
		Assert.assertNotNull("Complex element should be present", pojo.getValue());
		PodamTestUtils.assertListElementsType(pojo.getList(), Long.class);
		PodamTestUtils.assertMapElementsType(pojo.getMap(), Integer.class, String.class);
		Assert.assertNotNull("Complex element should not be empty",
				pojo.getValue().getValue());
		Assert.assertEquals("Wrong element type", Character.class,
				pojo.getValue().getValue().getClass());
	}
}

@@ -27,24 +27,83 @@
 test.unit;%0A%0A
+import java.beans.beancontext.BeanContextServicesSupport;%0A%0A
 import org.j
@@ -2080,11 +2080,200 @@
 s());%0A%09%7D
+%0A%0A%09@Test%0A%09public void testLoopInFillingReadOnlyFields() %7B%0A%09%09Object pojo = factory.manufacturePojo(BeanContextServicesSupport.class);%0A%09%09Assert.assertNotNull(%22Manufacturing failed%22, pojo);%0A%09%7D
 %0A%7D%0A

Test loop in filling read-only complex fields