Skip to content

Conversation

@vavrtom
Copy link
Contributor

@vavrtom vavrtom commented Sep 11, 2019

Divided test testCreateValidation to

  • testSelectorNumberMustBePositiveOnCreate
  • testConnectionThreadPoolSizeMustBePositiveOnCreate
  • testSelectorNumberMustBeLessOrEqualToThePoolSizeOnCreate

and test testChangeValidation to

  • testSelectorNumberMustBePositiveOnChange
  • testConnectionThreadPoolSizeMustBePositiveOnChange
  • testSelectorNumberMustBeLessOrEqualToThePoolSizeOnChange

Copy link
Contributor

@alex-rufous alex-rufous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to split positive and negative tests into separate methods.
The positive tests can be strengthened with asserts verifying attributes values


@Test
public void testCreateValidation()
public void testSelectorNumberMustBePositiveOnCreate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest splitting positive and negative tests into separate methods

public void testCreateValidation()
public void testSelectorNumberMustBePositiveOnCreate()
{
createVirtualHost(getTestName(), Collections.singletonMap(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, "1"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It make sense to verify that attribute "numberOfSelectors" is indeed set to the specified value, for example

Map<String, Object> attributes = Collections.singletonMap(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, "1"); final QueueManagingVirtualHost<?> vh = createVirtualHost(getTestName(), attributes); assertEquals(1, vh.getNumberOfSelectors());

}

@Test
public void testConnectionThreadPoolSizeMustBePositiveOnCreate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, split method into positive and negative tests

final Map<String, Object> vhAttributes = new HashMap<>();
vhAttributes.put(QueueManagingVirtualHost.CONNECTION_THREAD_POOL_SIZE, 1);
vhAttributes.put(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, 1);
createVirtualHost(getTestName(), vhAttributes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test can be strengthen with asserts verifying that specified values are indeed set on the corresponding attributes

}

@Test
public void testSelectorNumberMustBeLessOrEqualToThePoolSizeOnCreate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest splitting positive and negative tests into separate methods

{
QueueManagingVirtualHost<?> virtualHost = createVirtualHost(getTestName());
final QueueManagingVirtualHost<?> virtualHost = createVirtualHost(getTestName());
virtualHost.setAttributes(Collections.singletonMap(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, "1"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test can be strengthen with asserts verifying that specified values are indeed set on the corresponding attributes

}

@Test
public void testConnectionThreadPoolSizeMustBePositiveOnChange()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest splitting positive and negative tests into separate methods

final Map<String, Object> vhAttributes = new HashMap<>();
vhAttributes.put(QueueManagingVirtualHost.CONNECTION_THREAD_POOL_SIZE, 1);
vhAttributes.put(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, 1);
virtualHost.setAttributes(vhAttributes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test can be strengthen with asserts verifying that specified values are indeed set on the corresponding attributes

}

@Test
public void testSelectorNumberMustBeLessOrEqualToThePoolSizeOnChange()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest splitting positive and negative tests into separate methods

{
final QueueManagingVirtualHost<?> virtualHost = createVirtualHost(getTestName());
virtualHost.setAttributes(Collections.singletonMap(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, QueueManagingVirtualHost.DEFAULT_VIRTUALHOST_CONNECTION_THREAD_POOL_SIZE - 1));
virtualHost.setAttributes(Collections.singletonMap(QueueManagingVirtualHost.NUMBER_OF_SELECTORS, QueueManagingVirtualHost.DEFAULT_VIRTUALHOST_CONNECTION_THREAD_POOL_SIZE));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test can be strengthen with asserts verifying that specified values are indeed set on the corresponding attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants