businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
/** * If sub-partition values are given, they must not be blank. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationSubPartitionValueNotBlank() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(BLANK_TEXT), StorageEntity.MANAGED_STORAGE); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The sub-partition value [0] must not be blank", e.getMessage()); } }
/** * Asserts that business object definition name requiredness validation is working. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectDefinitionNameRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The business object definition name is required", e.getMessage()); } }
/** * Asserts that business object format file type requiredness validation is working. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatFileTypeRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The business object format file type is required", e.getMessage()); } }
/** * Asserts that storage name requiredness validation is working. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationStorageNameRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BLANK_TEXT); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The storage name is required", e.getMessage()); } }
/** * Asserts that business object format usage requiredness validation is working. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatUsageRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The business object format usage is required", e.getMessage()); } }
/** * Asserts that business object format version positive validation is working. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatVersionNegative() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, -1, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The business object format version must be greater than or equal to 0", e.getMessage()); } }
/** * Asserts that partition value requiredness validation is working. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationPartitionValueRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass()); Assert.assertEquals("thrown exception message", "The partition value is required", e.getMessage()); } }
/** * Storage must exist for this API to work. */ @Test public void testInvalidateUnregisteredBusinessObjectDataValidationStorageMustExist() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, "DOES_NOT_EXIST"); // Given a business object format try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API try { businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a ObjectNotFoundException, but no exception was thrown"); } catch (Exception e) { Assert.assertEquals("thrown exception type", ObjectNotFoundException.class, e.getClass()); Assert.assertEquals("thrown exception message", "Storage with name \"" + request.getStorageName() + "\" doesn't exist.", e.getMessage()); } }
businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
@Test public void testProcessBusinessObjectFormatVersionChangeNotificationEventHerdSqsNotificationNotEnabled() throws Exception { // Create a business object format entity. BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); // Get a business object data key. BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity); // Override configuration. Map<String, Object> overrideMap = new HashMap<>(); overrideMap.put(ConfigurationValue.HERD_NOTIFICATION_SQS_ENABLED.getKey(), false); modifyPropertySourceInEnvironment(overrideMap); try { // Trigger the notification. List<NotificationMessage> result = messageNotificationEventService .processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION); // Validate the results. assertTrue(CollectionUtils.isEmpty(result)); } finally { // Restore the property sources so we don't affect other tests. restorePropertySourceInEnvironment(); } }
businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
/** * Test case where S3 has 1 object, and herd has no object registered. The S3 object is registered under version 1 so there is a gap for version 0 of * registration. Expects no new registrations since the API does not consider the S3 objects after a gap. */ @Test public void testInvalidateUnregisteredBusinessObjectDataS31Herd0WithGap() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format // Given an object in S3 BusinessObjectFormatEntity businessObjectFormatEntity; try { businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 1); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call API BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); // Make assertions Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList()); Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size()); }
/** * Test case where herd and S3 are in sync because both have 1 object registered. Expects no new data registration. */ @Test public void testInvalidateUnregisteredBusinessObjectDataS31Herd1() throws Exception { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); // Given a business object format try { BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 0); createBusinessObjectDataEntityFromBusinessObjectDataInvalidateUnregisteredRequest(businessObjectFormatEntity, request, 0, true); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } // Call the API BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); // Make assertions Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList()); Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size()); }
try businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
@Test public void testProcessBusinessObjectFormatVersionChangeNotificationEvent() throws Exception { // Create a business object format entity. BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); // Get a business object data key. BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity); // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList( new NotificationMessageDefinition(MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE))))))); configurationDao.saveAndRefresh(configurationEntity); // Trigger the notification. List<NotificationMessage> result = messageNotificationEventService .processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION); // Validate the results. assertEquals(1, CollectionUtils.size(result)); businessObjectFormatServiceTestHelper .validateBusinessObjectFormatVersionChangeMessageWithXmlPayload(MESSAGE_TYPE, MESSAGE_DESTINATION, businessObjectFormatKey, HerdDaoSecurityHelper.SYSTEM_USER, businessObjectFormatKey.getBusinessObjectFormatVersion().toString(), NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION, Collections.singletonList(new MessageHeader(KEY, VALUE)), result.get(0)); }
PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
@Test public void testProcessBusinessObjectFormatVersionChangeNotificationEventWithNoMessageHeaders() throws Exception { // Create a business object format entity. BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); // Get a business object data key. BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity); // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList( new NotificationMessageDefinition(MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Trigger the notification. List<NotificationMessage> result = messageNotificationEventService .processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION); // Validate the results. assertEquals(1, CollectionUtils.size(result)); businessObjectFormatServiceTestHelper .validateBusinessObjectFormatVersionChangeMessageWithXmlPayload(MESSAGE_TYPE, MESSAGE_DESTINATION, businessObjectFormatKey, HerdDaoSecurityHelper.SYSTEM_USER, businessObjectFormatKey.getBusinessObjectFormatVersion().toString(), NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION, NO_MESSAGE_HEADERS, result.get(0)); }
PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);