test_class.declarator: attributeDaoHelper
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private AttributeDaoHelper attributeDaoHelper;
test_class.type: AttributeDaoHelper
test_class.var_name: attributeDaoHelper
test_class.declarator: businessObjectDataHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private BusinessObjectDataHelper businessObjectDataHelper;
test_class.type: BusinessObjectDataHelper
test_class.var_name: businessObjectDataHelper
test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/AttributeDaoHelperTest.java
test_class.identifier: AttributeDaoHelperTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testUpdateBusinessObjectDataAttributesAttributeAdded()
      {
          // Create a list of attributes.
          List<Attribute> attributes = Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE));
  
          // Create a business object data entity without attributes.
          BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
          businessObjectDataEntity.setAttributes(new ArrayList<>());
  
          // Call the method under test.
          attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, attributes);
  
          // Verify the external calls.
          verifyNoMoreInteractionsHelper();
  
          // Validate the results.
          assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
          BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
          assertEquals(businessObjectDataEntity, businessObjectDataAttributeEntity.getBusinessObjectData());
          assertEquals(ATTRIBUTE_NAME, businessObjectDataAttributeEntity.getName());
          assertEquals(ATTRIBUTE_VALUE, businessObjectDataAttributeEntity.getValue());
      }
test_case.class_method_signature: AttributeDaoHelperTest.testUpdateBusinessObjectDataAttributesAttributeAdded()
test_case.full_signature: @Test public void testUpdateBusinessObjectDataAttributesAttributeAdded()
test_case.identifier: testUpdateBusinessObjectDataAttributesAttributeAdded
test_case.invocations: asList setAttributes updateBusinessObjectDataAttributes verifyNoMoreInteractionsHelper assertEquals size getAttributes get getAttributes assertEquals getBusinessObjectData assertEquals getName assertEquals getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUpdateBusinessObjectDataAttributesAttributeAdded()
focal_class.declarator: businessObjectDataHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDataHelper businessObjectDataHelper;
focal_class.type: BusinessObjectDataHelper
focal_class.var_name: businessObjectDataHelper
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/AttributeDaoHelper.java
focal_class.identifier: AttributeDaoHelper
focal_class.class_method_signature: AttributeDaoHelper.updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_class.full_signature: public void updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_class.identifier: updateBusinessObjectDataAttributes
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_class.return: void
focal_class.signature: void updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_class.class_method_signature: AttributeDaoHelper.validateAttributesAgainstBusinessObjectDataAttributeDefinitions(final List<Attribute> attributes,
          final Collection<BusinessObjectDataAttributeDefinitionEntity> businessObjectDataAttributeDefinitionEntities)
focal_class.full_signature: public void validateAttributesAgainstBusinessObjectDataAttributeDefinitions(final List<Attribute> attributes,
          final Collection<BusinessObjectDataAttributeDefinitionEntity> businessObjectDataAttributeDefinitionEntities)
focal_class.identifier: validateAttributesAgainstBusinessObjectDataAttributeDefinitions
focal_class.modifiers: public
focal_class.parameters: (final List<Attribute> attributes,
          final Collection<BusinessObjectDataAttributeDefinitionEntity> businessObjectDataAttributeDefinitionEntities)
focal_class.return: void
focal_class.signature: void validateAttributesAgainstBusinessObjectDataAttributeDefinitions(final List<Attribute> attributes,
          final Collection<BusinessObjectDataAttributeDefinitionEntity> businessObjectDataAttributeDefinitionEntities)
focal_method.body: public void updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
      {
          // Load all existing attribute entities in a map with a "lowercase" attribute name as the key for case insensitivity.
          Map<String, BusinessObjectDataAttributeEntity> existingAttributeEntities = new HashMap<>();
          for (BusinessObjectDataAttributeEntity attributeEntity : businessObjectDataEntity.getAttributes())
          {
              String mapKey = attributeEntity.getName().toLowerCase();
              if (existingAttributeEntities.containsKey(mapKey))
              {
                  throw new IllegalStateException(String
                      .format("Found duplicate attribute with name \"%s\" for business object data. Business object data: {%s}", mapKey,
                          businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity)));
              }
              existingAttributeEntities.put(mapKey, attributeEntity);
          }
  
          // Process the list of attributes to determine that business object definition attribute entities should be created, updated, or deleted.
          List<BusinessObjectDataAttributeEntity> createdAttributeEntities = new ArrayList<>();
          List<BusinessObjectDataAttributeEntity> retainedAttributeEntities = new ArrayList<>();
          if (!CollectionUtils.isEmpty(attributes))
          {
              for (Attribute attribute : attributes)
              {
                  // Use a "lowercase" attribute name for case insensitivity.
                  String lowercaseAttributeName = attribute.getName().toLowerCase();
                  if (existingAttributeEntities.containsKey(lowercaseAttributeName))
                  {
                      // Check if the attribute value needs to be updated.
                      BusinessObjectDataAttributeEntity attributeEntity = existingAttributeEntities.get(lowercaseAttributeName);
                      if (!StringUtils.equals(attribute.getValue(), attributeEntity.getValue()))
                      {
                          // Update the business object attribute entity.
                          attributeEntity.setValue(attribute.getValue());
                      }
  
                      // Add this entity to the list of business object definition attribute entities to be retained.
                      retainedAttributeEntities.add(attributeEntity);
                  }
                  else
                  {
                      // Create a new business object attribute entity.
                      BusinessObjectDataAttributeEntity attributeEntity = new BusinessObjectDataAttributeEntity();
                      businessObjectDataEntity.getAttributes().add(attributeEntity);
                      attributeEntity.setBusinessObjectData(businessObjectDataEntity);
                      attributeEntity.setName(attribute.getName());
                      attributeEntity.setValue(attribute.getValue());
  
                      // Add this entity to the list of the newly created business object definition attribute entities.
                      createdAttributeEntities.add(attributeEntity);
                  }
              }
          }
  
          // Remove any of the currently existing attribute entities that did not get onto the retained entities list.
          businessObjectDataEntity.getAttributes().retainAll(retainedAttributeEntities);
  
          // Add all of the newly created business object definition attribute entities.
          businessObjectDataEntity.getAttributes().addAll(createdAttributeEntities);
      }
focal_method.class_method_signature: AttributeDaoHelper.updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_method.full_signature: public void updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_method.identifier: updateBusinessObjectDataAttributes
focal_method.invocations: getAttributes toLowerCase getName containsKey format businessObjectDataEntityAltKeyToString put isEmpty toLowerCase getName containsKey get equals getValue getValue setValue getValue add add getAttributes setBusinessObjectData setName getName setValue getValue add retainAll getAttributes addAll getAttributes
focal_method.modifiers: public
focal_method.parameters: (BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)
focal_method.return: void
focal_method.signature: void updateBusinessObjectDataAttributes(BusinessObjectDataEntity businessObjectDataEntity, final List<Attribute> attributes)