package uk.org.taverna.scufl2.api.property;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.net.URI;
import java.util.Set;

import org.junit.Test;

public class TestAddProperty {

	private static final URI EXAMPLE_COM = URI.create("http://example.com/");
	private static final URI CONSTANT = EXAMPLE_COM.resolve("#constant");
	private static final URI PROPERTY = EXAMPLE_COM.resolve("#property");
	private static final URI SOME_TYPE = EXAMPLE_COM.resolve("#SomeType");

	@Test
	public void addPropertyResource() throws Exception {
		PropertyResource propertyResource = new PropertyResource();
		PropertyResource propResource = propertyResource.addPropertyAsNewResource(PROPERTY, SOME_TYPE);
		// No need to fill in propResource as we can check same-ness below

		Set<PropertyObject> properties = propertyResource.getProperties().get(PROPERTY);
		assertEquals(1, properties.size());
		assertEquals(propResource, properties.iterator().next());
	}

	@Test
	public void addPropertyURI() throws Exception {
		PropertyResource propertyResource = new PropertyResource();
		propertyResource.addPropertyAsResourceURI(PROPERTY, CONSTANT);

		Set<PropertyObject> properties = propertyResource.getProperties().get(
				PROPERTY);
		assertEquals(1, properties.size());
		PropertyResource propRes = (PropertyResource) properties.iterator()
		.next();
		assertEquals(CONSTANT, propRes.getResourceURI());
		assertNull(propRes.getTypeURI());
		assertTrue(propRes.getProperties().isEmpty());
	}

	@Test
	public void addStringLiteral() throws Exception {
		PropertyResource propertyResource = new PropertyResource();
		propertyResource.addPropertyAsString(PROPERTY, "Hello there");

		Set<PropertyObject> properties = propertyResource.getProperties().get(PROPERTY);
		assertEquals(1, properties.size());
		PropertyLiteral propertyLiteral = (PropertyLiteral) properties.iterator().next();
		assertEquals("Hello there", propertyLiteral.getLiteralValue());
		assertEquals(PropertyLiteral.XSD_STRING, propertyLiteral.getLiteralType());
	}

}

@@ -583,32 +583,37 @@
 void addProperty
+AsNew
 Resource() throw
@@ -1072,16 +1072,26 @@
 Property
+AsResource
 URI() th
@@ -1610,21 +1610,24 @@
  add
-StringLiteral
+PropertyAsString
 () t

Test method names to reflect tested methods