@Test public void testCreatePartitionKeyGroup() { // Create a partition key group. PartitionKeyGroup resultPartitionKeyGroup = partitionKeyGroupServiceTestHelper.createPartitionKeyGroup(PARTITION_KEY_GROUP); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, resultPartitionKeyGroup); }
@Test public void testCreatePartitionKeyGroupMissingRequiredParameters() { // Try to perform a create without specifying partition key group name. try { partitionKeyGroupServiceTestHelper.createPartitionKeyGroup(BLANK_TEXT); fail("Should throw an IllegalArgumentException when partition key group is not specified."); } catch (IllegalArgumentException e) { assertEquals("A partition key group name must be specified.", e.getMessage()); } }
@Test public void testCreatePartitionKeyGroupTrimParameters() { // Create a partition key group by passing partition key group name with leading and trailing whitespace characters. PartitionKeyGroup resultPartitionKeyGroup = partitionKeyGroupServiceTestHelper.createPartitionKeyGroup(addWhitespace(PARTITION_KEY_GROUP)); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, resultPartitionKeyGroup); }
@Test public void testCreatePartitionKeyGroupInvalidParameters() { // Try to perform a create when partition key group name contains a forward slash character. try { partitionKeyGroupServiceTestHelper.createPartitionKeyGroup(addSlash(PARTITION_KEY_GROUP)); fail("Should throw an IllegalArgumentException when partition key group name contains a forward slash character."); } catch (IllegalArgumentException e) { assertEquals("Partition key group name can not contain a forward slash character.", e.getMessage()); } }
@Test public void testCreatePartitionKeyGroupEntityAlreadyExists() { // Create and persist a partition key group entity. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP); // Try to create a partition key group with the same partition key group name. try { partitionKeyGroupServiceTestHelper.createPartitionKeyGroup(PARTITION_KEY_GROUP); } catch (AlreadyExistsException e) { assertEquals(String.format("Unable to create partition key group with name \"%s\" because it already exists.", PARTITION_KEY_GROUP), e.getMessage()); } }