/** * Returns a list of business object data attributes created using hard coded test values. * * @return the newly created list of business object data attributes */ protected List<Attribute> getTestAttributes() { List<Attribute> attributes = new ArrayList<>(); Attribute attribute1 = new Attribute(); attributes.add(attribute1); attribute1.setName(ATTRIBUTE_NAME_1_MIXED_CASE); attribute1.setValue(ATTRIBUTE_VALUE_1); Attribute attribute2 = new Attribute(); attributes.add(attribute2); attribute2.setName(ATTRIBUTE_NAME_2_MIXED_CASE); attribute2.setValue(ATTRIBUTE_VALUE_2); return attributes; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); strategy.appendField(locator, this, "value", buffer, theValue, (this.value!= null)); } return buffer; }
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
/** * Validates the attributes. * * @param attributes the attributes to validate. Null shouldn't be specified. * @return the validated attribute map * @throws IllegalArgumentException if any invalid attributes were found. */ public Map<String, String> validateAttributes(List<Attribute> attributes) throws IllegalArgumentException { // Validate attributes if they are specified. Map<String, String> attributeNameValidationMap = new HashMap<>(); if (!CollectionUtils.isEmpty(attributes)) { for (Attribute attribute : attributes) { attribute.setName(alternateKeyHelper.validateStringParameter("An", "attribute name", attribute.getName())); // Ensure the attribute key isn't a duplicate by using a map with a "lowercase" name as the key for case insensitivity. String validationMapKey = attribute.getName().toLowerCase(); if (attributeNameValidationMap.containsKey(validationMapKey)) { throw new IllegalArgumentException("Duplicate attribute name found: " + attribute.getName()); } attributeNameValidationMap.put(validationMapKey, attribute.getValue()); } } return attributeNameValidationMap; }
/** * Create an instance of {@link Attribute } * */ public Attribute createAttribute() { return new Attribute(); }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof Attribute) { final Attribute copy = ((Attribute) draftCopy); if (nameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceName; sourceName = this.getName(); String copyName = ((String) strategy.copy(LocatorUtils.property(locator, "name", sourceName), sourceName, (this.name!= null))); copy.setName(copyName); } else { if (nameShouldBeCopiedAndSet == Boolean.FALSE) { if (valueShouldBeCopiedAndSet == Boolean.TRUE) { String sourceValue; sourceValue = this.getValue(); String copyValue = ((String) strategy.copy(LocatorUtils.property(locator, "value", sourceValue), sourceValue, (this.value!= null))); copy.setValue(copyValue); } else { if (valueShouldBeCopiedAndSet == Boolean.FALSE) {
String s3KeyPrefix = "s3KeyPrefix"; StorageUnit storageUnit = new StorageUnit(new Storage("storageName", s3KeyPrefix, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); Attribute attribute = new Attribute("name", "value"); BusinessObjectData businessObjectData = new BusinessObjectData(1234, "businessObjectDefinitionNamespace", "businessObjectDefinitionName", "formatUsage", "formatFileType", 2345, assertEquals("storageName", resultDto.getStorageName()); HashMap<String, String> expectedAttributes = new HashMap<>(); expectedAttributes.put(attribute.getName(), attribute.getValue()); assertEquals(expectedAttributes, resultDto.getAttributes()); assertEquals(new ArrayList<>(), resultDto.getBusinessObjectDataParents());
@Test public void testUpdateStorageAttributesStorageHasDuplicateAttributes() { // Create and persist a valid storage. StorageCreateRequest request = getNewStorageCreateRequest(); Storage storage = storageService.createStorage(request); // Add a duplicate attribute to the storage. StorageEntity storageEntity = storageDao.getStorageByName(storage.getName()); StorageAttributeEntity storageAttributeEntity = new StorageAttributeEntity(); storageAttributeEntity.setStorage(storageEntity); storageAttributeEntity.setName(request.getAttributes().get(0).getName().toUpperCase()); storageEntity.getAttributes().add(storageAttributeEntity); storageDao.saveAndRefresh(storageEntity); // Try to update attributes for the storage. try { storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2())); } catch (IllegalStateException e) { assertEquals(String.format("Found duplicate attribute with name \"%s\" for \"%s\" storage.", request.getAttributes().get(0).getName().toLowerCase(), storage.getName()), e.getMessage()); } }
request.getBusinessObjectDataAttributes().get(0).setName(BLANK_TEXT); try
/** * Create an instance of {@link Attribute } * */ public Attribute createAttribute() { return new Attribute(); }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof Attribute) { final Attribute copy = ((Attribute) draftCopy); if (nameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceName; sourceName = this.getName(); String copyName = ((String) strategy.copy(LocatorUtils.property(locator, "name", sourceName), sourceName, (this.name!= null))); copy.setName(copyName); } else { if (nameShouldBeCopiedAndSet == Boolean.FALSE) { if (valueShouldBeCopiedAndSet == Boolean.TRUE) { String sourceValue; sourceValue = this.getValue(); String copyValue = ((String) strategy.copy(LocatorUtils.property(locator, "value", sourceValue), sourceValue, (this.value!= null))); copy.setValue(copyValue); } else { if (valueShouldBeCopiedAndSet == Boolean.FALSE) {
/** * Validates the attributes. * * @param attributes the attributes to validate. Null shouldn't be specified. * @return the validated attribute map * @throws IllegalArgumentException if any invalid attributes were found. */ public Map<String, String> validateAttributes(List<Attribute> attributes) throws IllegalArgumentException { // Validate attributes if they are specified. Map<String, String> attributeNameValidationMap = new HashMap<>(); if (!CollectionUtils.isEmpty(attributes)) { for (Attribute attribute : attributes) { attribute.setName(alternateKeyHelper.validateStringParameter("An", "attribute name", attribute.getName())); // Ensure the attribute key isn't a duplicate by using a map with a "lowercase" name as the key for case insensitivity. String validationMapKey = attribute.getName().toLowerCase(); if (attributeNameValidationMap.containsKey(validationMapKey)) { throw new IllegalArgumentException("Duplicate attribute name found: " + attribute.getName()); } attributeNameValidationMap.put(validationMapKey, attribute.getValue()); } } return attributeNameValidationMap; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); strategy.appendField(locator, this, "value", buffer, theValue, (this.value!= null)); } return buffer; }
@Test(expected = PersistenceException.class) public void testCreateBusinessObjectDataAttributeValueTooLarge() throws Exception { final BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(); // Create and add a duplicate attribute which is not allowed. Attribute newAttribute = new Attribute(); newAttribute.setName("Valid Name"); newAttribute.setValue(new String(new char[4001]).replace('\0', 'A')); // Test value greater than 4000 byte limit. businessObjectDataCreateRequest.getAttributes().add(newAttribute); executeWithoutLogging(SqlExceptionHelper.class, new Command() { @Override public void execute() { // Create the business object data which is invalid. businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest); } }); }
/** * Create an instance of {@link Attribute } * */ public Attribute createAttribute() { return new Attribute(); }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof Attribute) { final Attribute copy = ((Attribute) draftCopy); if (nameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceName; sourceName = this.getName(); String copyName = ((String) strategy.copy(LocatorUtils.property(locator, "name", sourceName), sourceName, (this.name!= null))); copy.setName(copyName); } else { if (nameShouldBeCopiedAndSet == Boolean.FALSE) { if (valueShouldBeCopiedAndSet == Boolean.TRUE) { String sourceValue; sourceValue = this.getValue(); String copyValue = ((String) strategy.copy(LocatorUtils.property(locator, "value", sourceValue), sourceValue, (this.value!= null))); copy.setValue(copyValue); } else { if (valueShouldBeCopiedAndSet == Boolean.FALSE) {
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); strategy.appendField(locator, this, "value", buffer, theValue, (this.value!= null)); } return buffer; }