test_class.file: cmsdal/src/test/java/com/oneops/cms/dj/service/CmsRfcUtilTest.java
test_class.identifier: CmsRfcUtilTest
test_case.body: @Test
      public void testMergeRfcAndCi() {
          //create ci and rfc
          CmsRfcCI rfc = new CmsRfcCI();
          CmsRfcAttribute rfcAttribute_1 = createRfcAttribute("1");
          rfc.addAttribute(rfcAttribute_1);
  
          CmsRfcAttribute rfcAttribute_2 = createRfcAttribute("2");
          rfc.addAttribute(rfcAttribute_2);
  
          CmsCI ci = new CmsCI();
          ci.setNsPath("/test/ns/path");
          CmsRfcUtil rfcUtil = new CmsRfcUtil();
  
          CmsCIAttribute ciAttribute_1 = createCiAttribute("1");
          ci.addAttribute(ciAttribute_1);
  
          CmsCIAttribute ciAttribute_2 = createCiAttribute("2");
          ci.addAttribute(ciAttribute_2);
  
          ciAttribute_1.setDjValue("dj_value_1");
          ciAttribute_2.setDjValue("dj_value_2");
  
          //test that old values do get set in the rfc
          CmsRfcCI result = rfcUtil.mergeRfcAndCi(rfc, ci, "df");
          assertEquals(result.getAttribute("name-1").getOldValue(), ciAttribute_1.getDfValue());
          assertEquals(result.getAttribute("name-2").getOldValue(), ciAttribute_2.getDfValue());
  
          //test with dj values
  
          result = rfcUtil.mergeRfcAndCi(rfc, ci, "dj");
          assertEquals(result.getAttribute("name-1").getOldValue(), ciAttribute_1.getDjValue());
          assertEquals(result.getAttribute("name-2").getOldValue(), ciAttribute_2.getDjValue());
  
          //test if the attribute is not present in the rfc, it gets added
          CmsCIAttribute ciAttribute_3 = createCiAttribute("3");
          ci.addAttribute(ciAttribute_3);
  
          result = rfcUtil.mergeRfcAndCi(rfc, ci, "df");
  
          assertEquals(result.getAttribute("name-3").getNewValue(), ciAttribute_3.getDfValue());
  
          //test if the rfc is of type "add", all of ci's attributes do get set to rfc with "new value" as ci's attribute value
          // also test if the attribtue is not in rfc, it does get added in this case
  
          rfc.setRfcActionId(100);
          rfcAttribute_1.setNewValue("");
          rfc.addAttribute(rfcAttribute_1);
  
          result = rfcUtil.mergeRfcAndCi(rfc, ci, "df");
          assertEquals(result.getAttribute("name-1").getNewValue(), ciAttribute_1.getDfValue());
  
          CmsCIAttribute ciAttribute_4 = createCiAttribute("4");
          ci.addAttribute(ciAttribute_4);
  
          result = rfcUtil.mergeRfcAndCi(rfc, ci, "df");
  
          assertEquals(result.getAttribute("name-4").getNewValue(), ciAttribute_4.getDfValue());
      }
test_case.class_method_signature: CmsRfcUtilTest.testMergeRfcAndCi()
test_case.full_signature: @Test public void testMergeRfcAndCi()
test_case.identifier: testMergeRfcAndCi
test_case.invocations: createRfcAttribute addAttribute createRfcAttribute addAttribute setNsPath createCiAttribute addAttribute createCiAttribute addAttribute setDjValue setDjValue mergeRfcAndCi assertEquals getOldValue getAttribute getDfValue assertEquals getOldValue getAttribute getDfValue mergeRfcAndCi assertEquals getOldValue getAttribute getDjValue assertEquals getOldValue getAttribute getDjValue createCiAttribute addAttribute mergeRfcAndCi assertEquals getNewValue getAttribute getDfValue setRfcActionId setNewValue addAttribute mergeRfcAndCi assertEquals getNewValue getAttribute getDfValue createCiAttribute addAttribute mergeRfcAndCi assertEquals getNewValue getAttribute getDfValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMergeRfcAndCi()
focal_class.file: cmsdal/src/main/java/com/oneops/cms/dj/service/CmsRfcUtil.java
focal_class.identifier: CmsRfcUtil
focal_class.class_method_signature: CmsRfcUtil.mergeRfcRelAndCiRel(CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue)
focal_class.full_signature: public CmsRfcRelation mergeRfcRelAndCiRel(CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue)
focal_class.identifier: mergeRfcRelAndCiRel
focal_class.modifiers: public
focal_class.parameters: (CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue)
focal_class.return: CmsRfcRelation
focal_class.signature: CmsRfcRelation mergeRfcRelAndCiRel(CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue)
focal_class.class_method_signature: CmsRfcUtil.mergeRfcRelAndCiRel(CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue, boolean applyDeletes)
focal_class.full_signature: public CmsRfcRelation mergeRfcRelAndCiRel(CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue, boolean applyDeletes)
focal_class.identifier: mergeRfcRelAndCiRel
focal_class.modifiers: public
focal_class.parameters: (CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue, boolean applyDeletes)
focal_class.return: CmsRfcRelation
focal_class.signature: CmsRfcRelation mergeRfcRelAndCiRel(CmsRfcRelation rfcRel, CmsCIRelation ciRel, String cmAttrValue, boolean applyDeletes)
focal_class.class_method_signature: CmsRfcUtil.mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_class.full_signature: public CmsRfcCI mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_class.identifier: mergeRfcAndCi
focal_class.modifiers: public
focal_class.parameters: (CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_class.return: CmsRfcCI
focal_class.signature: CmsRfcCI mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_method.body: public CmsRfcCI mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType) {
  		if (rfcCi == null && ci == null) return null;
  		
  		//TODO check if we need to remove this
  		//if (rfcCi != null) {
  		//	if ("delete".equals(rfcCi.getRfcAction())) return null;
  		//}
  		
  		if (ci != null) {
  			if (rfcCi == null) rfcCi = new CmsRfcCI();
  			rfcCi.setCiId(ci.getCiId());
  			rfcCi.setCiClassName(ci.getCiClassName());
  			rfcCi.setCiClassId(ci.getCiClassId());
  			
  			if (rfcCi.getCiName() == null) rfcCi.setCiName(ci.getCiName());
  			if (rfcCi.getNsPath() == null) rfcCi.setNsPath(ci.getNsPath());
  			if (rfcCi.getNsId() == 0) rfcCi.setNsId(ci.getNsId());
  			if (rfcCi.getCiGoid() == null) rfcCi.setCiGoid(ci.getCiGoid());
  			if (rfcCi.getComments() == null) rfcCi.setComments(ci.getComments());
  			
  			rfcCi.setLastAppliedRfcId(ci.getLastAppliedRfcId());
  			rfcCi.setCiState(ci.getCiState());
  			
  			rfcCi.setRfcUpdated(rfcCi.getUpdated());
  			rfcCi.setRfcCreated(rfcCi.getCreated());
  			rfcCi.setRfcUpdatedBy(rfcCi.getUpdatedBy());
  			rfcCi.setRfcCreatedBy(rfcCi.getCreatedBy());
  			
  			rfcCi.setCreated(ci.getCreated());
  			rfcCi.setUpdated(ci.getUpdated());
  			rfcCi.setCreatedBy(ci.getCreatedBy());
  			rfcCi.setUpdatedBy(ci.getUpdatedBy());
  			
  			for (CmsBasicAttribute attr : ci.getAttributes().values()) {
  				CmsRfcAttribute rfcAttrib = null;
  				if (rfcCi.getAttributes().containsKey(attr.getAttributeName())) {
  					rfcAttrib = rfcCi.getAttributes().get(attr.getAttributeName());
  					if ("df".equalsIgnoreCase(valueType)) {
  						rfcAttrib.setOldValue(attr.getDfValue());
  					} else {
  						rfcAttrib.setOldValue(attr.getDjValue());
  					}
  				}
  				if (!rfcCi.getAttributes().containsKey(attr.getAttributeName())
  						|| rfcCi.getRfcActionId() == 100) { // in case the rfc is of type "Add"
  					if (rfcAttrib == null) {
  						rfcAttrib = new CmsRfcAttribute();
  						rfcAttrib.setAttributeId(attr.getAttributeId());
  						rfcAttrib.setAttributeName(attr.getAttributeName());
  					}
  
  					rfcAttrib.setOwner(attr.getOwner());
  					if ("df".equalsIgnoreCase(valueType)) {
  						rfcAttrib.setNewValue(attr.getDfValue());
  					} else {
  						rfcAttrib.setNewValue(attr.getDjValue());
  					}
  					rfcCi.addAttribute(rfcAttrib);
  				}
  			}
  		}
  		return rfcCi;
  	}
focal_method.class_method_signature: CmsRfcUtil.mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_method.full_signature: public CmsRfcCI mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_method.identifier: mergeRfcAndCi
focal_method.invocations: setCiId getCiId setCiClassName getCiClassName setCiClassId getCiClassId getCiName setCiName getCiName getNsPath setNsPath getNsPath getNsId setNsId getNsId getCiGoid setCiGoid getCiGoid getComments setComments getComments setLastAppliedRfcId getLastAppliedRfcId setCiState getCiState setRfcUpdated getUpdated setRfcCreated getCreated setRfcUpdatedBy getUpdatedBy setRfcCreatedBy getCreatedBy setCreated getCreated setUpdated getUpdated setCreatedBy getCreatedBy setUpdatedBy getUpdatedBy values getAttributes containsKey getAttributes getAttributeName get getAttributes getAttributeName equalsIgnoreCase setOldValue getDfValue setOldValue getDjValue containsKey getAttributes getAttributeName getRfcActionId setAttributeId getAttributeId setAttributeName getAttributeName setOwner getOwner equalsIgnoreCase setNewValue getDfValue setNewValue getDjValue addAttribute
focal_method.modifiers: public
focal_method.parameters: (CmsRfcCI rfcCi, CmsCI ci, String valueType)
focal_method.return: CmsRfcCI
focal_method.signature: CmsRfcCI mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType)