/* SPDX-License-Identifier: Apache-2.0 */

// This is a generated file - do not edit - changes should be made to the templates amd/or generator to generate this file with changes.

package org.odpi.openmetadata.accessservices.subjectarea.generated.server;

import java.util.*;

import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ArrayPropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.PrimitivePropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.PrimitiveDefCategory;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EnumPropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.MapPropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;
import org.odpi.openmetadata.accessservices.subjectarea.ffdc.exceptions.*;
import org.odpi.openmetadata.accessservices.subjectarea.properties.objects.common.SystemAttributes;
import org.odpi.openmetadata.accessservices.subjectarea.utilities.OMRSAPIHelper;

import org.odpi.openmetadata.accessservices.subjectarea.properties.enums.*;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
import static org.testng.Assert.assertEquals;
import org.odpi.openmetadata.accessservices.subjectarea.responses.*;

<$$$
import org.odpi.openmetadata.accessservices.subjectarea.generated.entities.<$$uEntityName$$>.<$$uEntityName$$>;
import org.odpi.openmetadata.accessservices.subjectarea.generated.entities.<$$uEntityName$$>.<$$uEntityName$$>References;
$$$>

 <$$RELATIONSHIP$
 import org.odpi.openmetadata.accessservices.subjectarea.generated.relationships.<$$uRelationshipName$$>.<$$uRelationshipName$$>;
 $$RELATIONSHIP$>

public class TestSubjectAreaBeansToAccessOMRS {

    @Mock
    private OMRSAPIHelper oMRSAPIHelper;

    @BeforeMethod

    public void setup() throws Exception{
        MockitoAnnotations.initMocks(this);
    }
    <$$$
@Test
    public void testCreate<$$uEntityName$$>() throws Exception {
        String testuserid = "userid1";
        String testguid1 = "testcreate<$$uEntityName$$>";
        SubjectAreaBeansToAccessOMRS subjectAreaBeansToAccessOMRS = new SubjectAreaBeansToAccessOMRS();

        EntityDetail mockEntity = new EntityDetail();
        InstanceProperties instanceProperties = new InstanceProperties();

        PrimitivePropertyValue primitivePropertyValue;
        ArrayPropertyValue arrayPropertyValue;
         <$$Attr$$
        primitivePropertyValue = new PrimitivePropertyValue();
        primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
        <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
        primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);
        instanceProperties.setProperty("<$$AttrName$$>", primitivePropertyValue);
        $$Attr$$>

        <$$AttrList$$
        primitivePropertyValue = new PrimitivePropertyValue();
        primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
        <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
        primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);

        arrayPropertyValue = new ArrayPropertyValue();
        arrayPropertyValue.setArrayCount(1);
        arrayPropertyValue.setArrayValue(0,primitivePropertyValue);
        instanceProperties.setProperty("<$$AttrName$$>", arrayPropertyValue);
        $$AttrList$$>

        EnumPropertyValue enumPropertyValue;
        <$$Enum$$
        enumPropertyValue = new EnumPropertyValue();
        // get the name of the first enumeration value as a sample data.
        enumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
        instanceProperties.setProperty("<$$EnumName$$>", enumPropertyValue);

        $$Enum$$>

        MapPropertyValue mapPropertyValue;
        // In the models we are generating from we only have map<String,String> types, this code assumes those types.
        PrimitivePropertyValue primitivePropertyValueForMap=null;
        InstanceProperties mapValues =null;

        <$$Map$$
        mapPropertyValue = new MapPropertyValue();
        primitivePropertyValueForMap = new PrimitivePropertyValue();
        primitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
        primitivePropertyValueForMap.setPrimitiveValue("test string value for map");

        mapValues = new InstanceProperties();
        mapValues.setProperty("a_new_property_name",primitivePropertyValueForMap);
        mapPropertyValue.setMapValues(mapValues);
        instanceProperties.setProperty("<$$MapName$$>", mapPropertyValue);

        $$Map$$>

        mockEntity.setProperties(instanceProperties);
        mockEntity.setGUID(testguid1);
        mockEntity.setVersion(1L);
        InstanceType typeOfEntity = new InstanceType();
        typeOfEntity.setTypeDefName("<$$uEntityName$$>");
        mockEntity.setType(typeOfEntity);

        when( oMRSAPIHelper.callOMRSAddEntity(anyString(),any())).thenReturn(mockEntity);
        // set the mock omrs in to the rest file.
        subjectAreaBeansToAccessOMRS.setOMRSAPIHelper(oMRSAPIHelper);
        <$$uEntityName$$> requested<$$uEntityName$$> = new <$$uEntityName$$>();
        SystemAttributes systemAttributes = new SystemAttributes();
        systemAttributes.setGUID(testguid1);
        requested<$$uEntityName$$>.setSystemAttributes(systemAttributes);

        <$$Attr$$
        requested<$$uEntityName$$>.set<$$uAttrName$$>(<$$AttrName$$>);

        $$Attr$$>

        <$$Enum$$
        EnumPropertyValue <$$uEnumType$$>EnumPropertyValue = new EnumPropertyValue();
        // get the name of the first enumeration value as a sample data.
        <$$uEnumType$$>EnumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
        instanceProperties.setProperty("<$$EnumName$$>", <$$uEnumType$$>EnumPropertyValue);

        requested<$$uEntityName$$>.set<$$uEnumName$$>(<$$uEnumType$$>.values()[0]);

        $$Enum$$>

        Map<String,String>  mapValue=null;

        <$$Map$$
        mapValue = new HashMap<>();
        mapValue.put("a_new_property_name","test string value for map");
        requested<$$uEntityName$$>.set<$$uMapName$$>(mapValue);
        $$Map$$>
        
        <$$uEntityName$$> returned<$$uEntityName$$> = subjectAreaBeansToAccessOMRS.create<$$uEntityName$$>(testuserid, requested<$$uEntityName$$>);
        <$$Attr$$
        assertEquals(requested<$$uEntityName$$>.get<$$uAttrName$$>(),returned<$$uEntityName$$>.get<$$uAttrName$$>());

        $$Attr$$>

        <$$Enum$$
        assertEquals(requested<$$uEntityName$$>.get<$$uEnumName$$>(),returned<$$uEntityName$$>.get<$$uEnumName$$>());

        $$Enum$$>

        <$$Map$$
        assertEquals(requested<$$uEntityName$$>.get<$$uMapName$$>(),returned<$$uEntityName$$>.get<$$uMapName$$>());

        $$Map$$>

    }    
    @Test
    public void testGet<$$uEntityName$$>ById() throws Exception {
        String testuserid = "userid1";
        String testguid1 = "testcallOMRSGetEntityByGuid-<$$uEntityName$$>-guid";
        SubjectAreaBeansToAccessOMRS subjectAreaBeansToAccessOMRS = new SubjectAreaBeansToAccessOMRS();

        EntityDetail mockEntity = new EntityDetail();

        InstanceProperties instanceProperties = new InstanceProperties();

        PrimitivePropertyValue primitivePropertyValue;
         <$$Attr$$
        primitivePropertyValue = new PrimitivePropertyValue();
        primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
        <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
        primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);
        instanceProperties.setProperty("<$$AttrName$$>", primitivePropertyValue);
        $$Attr$$>

        EnumPropertyValue enumPropertyValue;
        <$$Enum$$
        enumPropertyValue = new EnumPropertyValue();
        // get the name of the first enumeration value as a sample data.
        enumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
        instanceProperties.setProperty("<$$EnumName$$>", enumPropertyValue);

        $$Enum$$>

        MapPropertyValue mapPropertyValue =null;
        // In the models we are generating from we only have map<String,String> types, this code assumes those types.

        PrimitivePropertyValue primitivePropertyValueForMap=null;
        InstanceProperties mapValues=null;
        <$$Map$$
        mapPropertyValue = new MapPropertyValue();
        primitivePropertyValueForMap = new PrimitivePropertyValue();
        primitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
        primitivePropertyValueForMap.setPrimitiveValue("test string value for map");

        mapValues = new InstanceProperties();
        mapValues.setProperty("a_new_property_name",primitivePropertyValueForMap);
        mapPropertyValue.setMapValues(mapValues);
        instanceProperties.setProperty("<$$uMapName$$>", mapPropertyValue);

        $$Map$$>

        mockEntity.setProperties(instanceProperties);
        mockEntity.setGUID(testguid1);
        mockEntity.setVersion(1L);
        InstanceType typeOfEntity = new InstanceType();
        typeOfEntity.setTypeDefName("<$$uEntityName$$>");
        mockEntity.setType(typeOfEntity);

        when( oMRSAPIHelper.callOMRSGetEntityByGuid(anyString(),anyString())).thenReturn(mockEntity);
        // set the mock omrs in to the rest file.
        subjectAreaBeansToAccessOMRS.setOMRSAPIHelper(oMRSAPIHelper);
        <$$uEntityName$$> <$$EntityName$$>Entity = subjectAreaBeansToAccessOMRS.get<$$uEntityName$$>ById(testuserid, testguid1);
        <$$Attr$$
        assertEquals(<$$EntityName$$>Entity.get<$$uAttrName$$>(),<$$AttrName$$>);
        $$Attr$$>

    }
    @Test
        public void testUpdate<$$uEntityName$$>() throws Exception {
            String testuserid = "userid1";
            String testguid1 = "testUpdate<$$uEntityName$$>";
            SubjectAreaBeansToAccessOMRS subjectAreaBeansToAccessOMRS = new SubjectAreaBeansToAccessOMRS();

            EntityDetail mockEntity = new EntityDetail();
            InstanceProperties instanceProperties = new InstanceProperties();

            PrimitivePropertyValue primitivePropertyValue;
             <$$Attr$$
            primitivePropertyValue = new PrimitivePropertyValue();
            primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
            <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
            primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);
            instanceProperties.setProperty("<$$AttrName$$>", primitivePropertyValue);
            $$Attr$$>

            EnumPropertyValue enumPropertyValue;
            <$$Enum$$
            enumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            enumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", enumPropertyValue);

            $$Enum$$>

            MapPropertyValue mapPropertyValue;
            // In the models we are generating from we only have map<String,String> types, this code assumes those types.
            PrimitivePropertyValue primitivePropertyValueForMap=null;
            InstanceProperties mapValues =null;

            <$$Map$$
            mapPropertyValue = new MapPropertyValue();
            primitivePropertyValueForMap = new PrimitivePropertyValue();
            primitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            primitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            mapValues = new InstanceProperties();
            mapValues.setProperty("a_new_property_name",primitivePropertyValueForMap);
            mapPropertyValue.setMapValues(mapValues);
            instanceProperties.setProperty("<$$MapName$$>", mapPropertyValue);

            $$Map$$>

            mockEntity.setProperties(instanceProperties);
            mockEntity.setGUID(testguid1);
            mockEntity.setVersion(1L);
            InstanceType typeOfEntity = new InstanceType();
            typeOfEntity.setTypeDefName("<$$uEntityName$$>");
            mockEntity.setType(typeOfEntity);

            when( oMRSAPIHelper.callOMRSUpdateEntity(anyString(),any())).thenReturn(mockEntity);
            // set the mock omrs in to the rest file.
            subjectAreaBeansToAccessOMRS.setOMRSAPIHelper(oMRSAPIHelper);
            <$$uEntityName$$> requested<$$uEntityName$$> = new <$$uEntityName$$>();
            SystemAttributes systemAttributes = new SystemAttributes();
            systemAttributes.setGUID(testguid1);
            requested<$$uEntityName$$>.setSystemAttributes(systemAttributes);

            <$$Attr$$
            requested<$$uEntityName$$>.set<$$uAttrName$$>(<$$AttrName$$>);

            $$Attr$$>

            <$$Enum$$
            EnumPropertyValue <$$uEnumType$$>EnumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            <$$uEnumType$$>EnumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", <$$uEnumType$$>EnumPropertyValue);

            requested<$$uEntityName$$>.set<$$uEnumName$$>(<$$uEnumType$$>.values()[0]);

            $$Enum$$>


            PrimitivePropertyValue testPrimitivePropertyValueForMap=null;
            InstanceProperties testMapValues =null;
            MapPropertyValue testMapPropertyValue=null;
            Map<String,String>  mapValue=null;

            <$$Map$$
            testMapPropertyValue = new MapPropertyValue();

            testPrimitivePropertyValueForMap = new PrimitivePropertyValue();
            testPrimitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            testPrimitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            testMapValues = new InstanceProperties();
            testMapValues.setProperty("a_new_property_name",testPrimitivePropertyValueForMap);

            mapValue = new HashMap<>();
            mapValue.put("a_new_property_name","test string value for map");
            requested<$$uEntityName$$>.set<$$uMapName$$>(mapValue);
            $$Map$$>

            <$$uEntityName$$> returned<$$uEntityName$$> = subjectAreaBeansToAccessOMRS.update<$$uEntityName$$>(testuserid,requested<$$uEntityName$$>);
            <$$Attr$$
            assertEquals(requested<$$uEntityName$$>.get<$$uAttrName$$>(),returned<$$uEntityName$$>.get<$$uAttrName$$>());

            $$Attr$$>

            <$$Enum$$
            assertEquals(requested<$$uEntityName$$>.get<$$uEnumName$$>(),returned<$$uEntityName$$>.get<$$uEnumName$$>());

            $$Enum$$>

            <$$Map$$
            assertEquals(requested<$$uEntityName$$>.get<$$uMapName$$>(),returned<$$uEntityName$$>.get<$$uMapName$$>());

            $$Map$$>

        }
    $$$>

    <$$RELATIONSHIP$

    @Test
        public void testCreate<$$uRelationshipName$$>() throws Exception {
            String testuserid = "userid1";
            String testguid1 = "testcreate<$$uRelationshipName$$>";
            SubjectAreaBeansToAccessOMRS subjectAreaBeansToAccessOMRS = new SubjectAreaBeansToAccessOMRS();

            Relationship mockRelationship = new Relationship();
            InstanceProperties instanceProperties = new InstanceProperties();

            PrimitivePropertyValue primitivePropertyValue;
             <$$Attr$$
            primitivePropertyValue = new PrimitivePropertyValue();
            primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
            <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
            primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);
            instanceProperties.setProperty("<$$AttrName$$>", primitivePropertyValue);
            $$Attr$$>

            EnumPropertyValue enumPropertyValue;
            <$$Enum$$
            enumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            enumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", enumPropertyValue);

            $$Enum$$>

            MapPropertyValue mapPropertyValue;
            // In the models we are generating from we only have map<String,String> types, this code assumes those types.
            <$$Map$$
            mapPropertyValue = new MapPropertyValue();
            PrimitivePropertyValue primitivePropertyValueForMap = new PrimitivePropertyValue();
            primitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            primitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            InstanceProperties mapValues = new InstanceProperties();
            mapValues.setProperty("a_new_property_name",primitivePropertyValueForMap);
            mapPropertyValue.setMapValues(mapValues);
            instanceProperties.setProperty("<$$uMapName$$>", mapPropertyValue);

            $$Map$$>

            mockRelationship.setProperties(instanceProperties);
            mockRelationship.setGUID(testguid1);
            mockRelationship.setVersion(1L);
            InstanceType typeOfRelationship = new InstanceType();
            typeOfRelationship.setTypeDefName("<$$uRelationshipName$$>");
            mockRelationship.setType(typeOfRelationship);

            mockRelationship.setEntityOnePropertyName("<$$uRelationshipEntity1$$>");
            mockRelationship.setEntityTwoPropertyName("<$$uRelationshipEntity2$$>");
            EntityProxy entityProxy1 = new EntityProxy();
            EntityProxy entityProxy2 = new EntityProxy();
            InstanceType type1 = new InstanceType();
            type1.setTypeDefName("<$$uRelationshipEntityType1$$>");
            InstanceType type2 = new InstanceType();
            type2.setTypeDefName("<$$uRelationshipEntityType2$$>");
            entityProxy1.setType(type1);
            entityProxy2.setType(type2);
            mockRelationship.setEntityOneProxy(entityProxy1);
            mockRelationship.setEntityTwoProxy(entityProxy2);

            when( oMRSAPIHelper.callOMRSAddRelationship(anyString(),any())).thenReturn(mockRelationship);
            // set the mock omrs in to the rest file.
            subjectAreaBeansToAccessOMRS.setOMRSAPIHelper(oMRSAPIHelper);
            <$$uRelationshipName$$> requested<$$uRelationshipName$$> = new <$$uRelationshipName$$>();
            SystemAttributes systemAttributes = new SystemAttributes();
            systemAttributes.setVersion(1L);
            requested<$$uRelationshipName$$>.setSystemAttributes(systemAttributes);

            <$$Attr$$
            requested<$$uRelationshipName$$>.set<$$uAttrName$$>(<$$AttrName$$>);

            $$Attr$$>

            <$$Enum$$
            EnumPropertyValue <$$uEnumType$$>EnumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            <$$uEnumType$$>EnumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", <$$uEnumType$$>EnumPropertyValue);

            requested<$$uRelationshipName$$>.set<$$uEnumName$$>(<$$uEnumType$$>.values()[0]);

            $$Enum$$>

            MapPropertyValue testMapPropertyValue = null;
            InstanceProperties testMapValues =null;
            PrimitivePropertyValue testPrimitivePropertyValueForMap=null;
            <$$Map$$
            testMapPropertyValue = new MapPropertyValue();

            testPrimitivePropertyValueForMap = new PrimitivePropertyValue();
            testPrimitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            testPrimitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            testMapValues = new InstanceProperties();
            testMapValues.setProperty("a_new_property_name",testPrimitivePropertyValueForMap);

            testMapPropertyValue.setMapValues(mapValues);
            instanceProperties.setProperty("<$$uMapName$$>", testMapPropertyValue);
            $$Map$$>

            <$$uRelationshipName$$> returned<$$uRelationshipName$$> = subjectAreaBeansToAccessOMRS.create<$$uRelationshipName$$>Relationship(testuserid, requested<$$uRelationshipName$$>);
            <$$Attr$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uAttrName$$>(),returned<$$uRelationshipName$$>.get<$$uAttrName$$>());

            $$Attr$$>

            <$$Enum$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uEnumName$$>(),returned<$$uRelationshipName$$>.get<$$uEnumName$$>());

            $$Enum$$>

            <$$Map$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uMapName$$>(),returned<$$uRelationshipName$$>.get<$$uMapName$$>());

            $$Map$$>

        }

        @Test
        public void testGet<$$uRelationshipName$$>() throws Exception {
            String testuserid = "userid1";
            String testguid1 = "testGet<$$uRelationshipName$$>";
            SubjectAreaBeansToAccessOMRS subjectAreaBeansToAccessOMRS = new SubjectAreaBeansToAccessOMRS();

            Relationship mockRelationship = new Relationship();
            InstanceProperties instanceProperties = new InstanceProperties();

            PrimitivePropertyValue primitivePropertyValue;
             <$$Attr$$
            primitivePropertyValue = new PrimitivePropertyValue();
            primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
            <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
            primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);
            instanceProperties.setProperty("<$$AttrName$$>", primitivePropertyValue);
            $$Attr$$>

            EnumPropertyValue enumPropertyValue;
            <$$Enum$$
            enumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            enumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", enumPropertyValue);

            $$Enum$$>

            // In the models we are generating from we only have map<String,String> types, this code assumes those types.
            MapPropertyValue mapPropertyValue = null;
            InstanceProperties mapValues =null;
            PrimitivePropertyValue primitivePropertyValueForMap =null;

            <$$Map$$
            mapPropertyValue = new MapPropertyValue();
            primitivePropertyValueForMap = new PrimitivePropertyValue();
            primitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            primitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            mapValues = new InstanceProperties();
            mapValues.setProperty("a_new_property_name",primitivePropertyValueForMap);
            mapPropertyValue.setMapValues(mapValues);
            instanceProperties.setProperty("<$$uMapName$$>", mapPropertyValue);

            $$Map$$>

            mockRelationship.setProperties(instanceProperties);
            mockRelationship.setGUID(testguid1);
            mockRelationship.setVersion(1L);
            InstanceType typeOfRelationship = new InstanceType();
            typeOfRelationship.setTypeDefName("<$$uRelationshipName$$>");
            mockRelationship.setType(typeOfRelationship);

            mockRelationship.setEntityOnePropertyName("<$$uRelationshipEntity1$$>");
            mockRelationship.setEntityTwoPropertyName("<$$uRelationshipEntity2$$>");
            EntityProxy entityProxy1 = new EntityProxy();
            EntityProxy entityProxy2 = new EntityProxy();
            InstanceType type1 = new InstanceType();
            type1.setTypeDefName("<$$uRelationshipEntityType1$$>");
            InstanceType type2 = new InstanceType();
            type2.setTypeDefName("<$$uRelationshipEntityType2$$>");
            entityProxy1.setType(type1);
            entityProxy2.setType(type2);
            mockRelationship.setEntityOneProxy(entityProxy1);
            mockRelationship.setEntityTwoProxy(entityProxy2);

            when( oMRSAPIHelper.callOMRSGetRelationshipByGuid(anyString(),anyString())).thenReturn(mockRelationship);
            // set the mock omrs in to the rest file.
            subjectAreaBeansToAccessOMRS.setOMRSAPIHelper(oMRSAPIHelper);
            <$$uRelationshipName$$> requested<$$uRelationshipName$$> = new <$$uRelationshipName$$>();

            <$$Attr$$
            requested<$$uRelationshipName$$>.set<$$uAttrName$$>(<$$AttrName$$>);

            $$Attr$$>

            <$$Enum$$
            EnumPropertyValue <$$uEnumType$$>EnumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            <$$uEnumType$$>EnumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", <$$uEnumType$$>EnumPropertyValue);

            requested<$$uRelationshipName$$>.set<$$uEnumName$$>(<$$uEnumType$$>.values()[0]);

            $$Enum$$>
            MapPropertyValue testMapPropertyValue = null;
            InstanceProperties testMapValues =null;
            PrimitivePropertyValue testPrimitivePropertyValueForMap=null;
            MapPropertyValue testMapPropertyValue = null;

            <$$Map$$
            testMapPropertyValue = new MapPropertyValue();
            testPrimitivePropertyValueForMap = new PrimitivePropertyValue();
            testPrimitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            testPrimitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            testMapValues = new InstanceProperties();
            testMapValues.setProperty("a_new_property_name",testPrimitivePropertyValueForMap);

            testMapPropertyValue.setMapValues(testMapValues);
            instanceProperties.setProperty("<$$uMapName$$>", testMapPropertyValue);
            $$Map$$>

            <$$uRelationshipName$$> returned<$$uRelationshipName$$> = subjectAreaBeansToAccessOMRS.get<$$uRelationshipName$$>RelationshipByGuid(testuserid, testguid1);
            <$$Attr$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uAttrName$$>(),returned<$$uRelationshipName$$>.get<$$uAttrName$$>());

            $$Attr$$>

            <$$Enum$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uEnumName$$>(),returned<$$uRelationshipName$$>.get<$$uEnumName$$>());

            $$Enum$$>

            <$$Map$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uMapName$$>(),returned<$$uRelationshipName$$>.get<$$uMapName$$>());

            $$Map$$>

        }
        @Test
        public void testUpdate<$$uRelationshipName$$>() throws Exception {
            String testuserid = "userid1";
            String testguid1 = "testUpdate<$$uRelationshipName$$>";
            SubjectAreaBeansToAccessOMRS subjectAreaBeansToAccessOMRS = new SubjectAreaBeansToAccessOMRS();

            Relationship mockRelationship = new Relationship();
            InstanceProperties instanceProperties = new InstanceProperties();

            PrimitivePropertyValue primitivePropertyValue;
             <$$Attr$$
            primitivePropertyValue = new PrimitivePropertyValue();
            primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_<$$uAttrType$$>);
            <$$AttrType$$> <$$AttrName$$> = <$$AttrValue$$>;
            primitivePropertyValue.setPrimitiveValue(<$$AttrName$$>);
            instanceProperties.setProperty("<$$AttrName$$>", primitivePropertyValue);
            $$Attr$$>

            EnumPropertyValue enumPropertyValue;
            <$$Enum$$
            enumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            enumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", enumPropertyValue);

            $$Enum$$>

            MapPropertyValue mapPropertyValue=null;
            PrimitivePropertyValue primitivePropertyValueForMap = null;
            InstanceProperties mapValues =null;

            // In the models we are generating from we only have map<String,String> types, this code assumes those types.
            <$$Map$$
            mapPropertyValue = new MapPropertyValue();
            primitivePropertyValueForMap = new PrimitivePropertyValue();
            primitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            primitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            mapValues = new InstanceProperties();
            mapValues.setProperty("a_new_property_name",primitivePropertyValueForMap);
            mapPropertyValue.setMapValues(mapValues);
            instanceProperties.setProperty("<$$uMapName$$>", mapPropertyValue);

            $$Map$$>

            mockRelationship.setProperties(instanceProperties);
            mockRelationship.setGUID(testguid1);
            mockRelationship.setVersion(1L);
            InstanceType typeOfRelationship = new InstanceType();
            typeOfRelationship.setTypeDefName("<$$uRelationshipName$$>");
            mockRelationship.setType(typeOfRelationship);

            mockRelationship.setEntityOnePropertyName("<$$uRelationshipEntity1$$>");
            mockRelationship.setEntityTwoPropertyName("<$$uRelationshipEntity2$$>");
            EntityProxy entityProxy1 = new EntityProxy();
            EntityProxy entityProxy2 = new EntityProxy();
            InstanceType type1 = new InstanceType();
            type1.setTypeDefName("<$$uRelationshipEntityType1$$>");
            InstanceType type2 = new InstanceType();
            type2.setTypeDefName("<$$uRelationshipEntityType2$$>");
            entityProxy1.setType(type1);
            entityProxy2.setType(type2);
            mockRelationship.setEntityOneProxy(entityProxy1);
            mockRelationship.setEntityTwoProxy(entityProxy2);

            when( oMRSAPIHelper.callOMRSUpdateRelationship(anyString(),any())).thenReturn(mockRelationship);
            // set the mock omrs in to the rest file.
            subjectAreaBeansToAccessOMRS.setOMRSAPIHelper(oMRSAPIHelper);
            <$$uRelationshipName$$> requested<$$uRelationshipName$$> = new <$$uRelationshipName$$>();

            <$$Attr$$
            requested<$$uRelationshipName$$>.set<$$uAttrName$$>(<$$AttrName$$>);

            $$Attr$$>

            <$$Enum$$
            EnumPropertyValue <$$uEnumType$$>EnumPropertyValue = new EnumPropertyValue();
            // get the name of the first enumeration value as a sample data.
            <$$uEnumType$$>EnumPropertyValue.setSymbolicName(<$$uEnumType$$>.values()[0].name());
            instanceProperties.setProperty("<$$EnumName$$>", <$$uEnumType$$>EnumPropertyValue);

            requested<$$uRelationshipName$$>.set<$$uEnumName$$>(<$$uEnumType$$>.values()[0]);

            $$Enum$$>

            PrimitivePropertyValue testPrimitivePropertyValueForMap=null;
            InstanceProperties testMapValues =null;
            MapPropertyValue testMapPropertyValue = null;

            <$$Map$$
            testMapPropertyValue = new MapPropertyValue();

            testPrimitivePropertyValueForMap= new PrimitivePropertyValue();
            testPrimitivePropertyValueForMap.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING);
            testPrimitivePropertyValueForMap.setPrimitiveValue("test string value for map");

            testMapValues = new InstanceProperties();
            testMapValues.setProperty("a_new_property_name",testPrimitivePropertyValueForMap);

            testMapPropertyValue.setMapValues(testMapValues);
            instanceProperties.setProperty("<$$uMapName$$>", testMapPropertyValue);
            $$Map$$>

            SystemAttributes systemAttributes = new SystemAttributes();
            systemAttributes.setVersion(1L);
            requested<$$uRelationshipName$$>.setSystemAttributes(systemAttributes);


            <$$uRelationshipName$$> returned<$$uRelationshipName$$> = subjectAreaBeansToAccessOMRS.update<$$uRelationshipName$$>Relationship(testuserid, requested<$$uRelationshipName$$>);
            <$$Attr$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uAttrName$$>(),returned<$$uRelationshipName$$>.get<$$uAttrName$$>());

            $$Attr$$>

            <$$Enum$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uEnumName$$>(),returned<$$uRelationshipName$$>.get<$$uEnumName$$>());

            $$Enum$$>

            <$$Map$$
            assertEquals(requested<$$uRelationshipName$$>.get<$$uMapName$$>(),returned<$$uRelationshipName$$>.get<$$uMapName$$>());

            $$Map$$>

        }
        $$RELATIONSHIP$>
}
