UTBotJava icon indicating copy to clipboard operation
UTBotJava copied to clipboard

Redundant brackets for mocks and class casts

Open alisevych opened this issue 3 years ago • 0 comments

Description

There are redundant brackets added around mock definitions. There are redundant brackets around class cast.

To Reproduce

  1. Install UnitTestBot plugin built from main in IntelliJ IDEA
  2. Open spring-petclinic
  3. Generate tests for OwnerController class
  4. Check all ownerRepositoryMock usages

Expected behavior

The whole expression should not be rounded with brackets. Class cast should have only required brackets, like following:

		when(ownerRepositoryMock.findById(any())).thenReturn((Owner) null);

Actual behavior

There are redundant brackets added around expressions in mock definitions. There are redundant brackets when class cast is used.

Screenshots, logs

		(when(ownerRepositoryMock.findById(any()))).thenReturn(((Owner) null));

Environment

IntelliJ IDEA version - CU/IU 2023.1 Project - Maven JDK - 1.8 / 17

Additional context

Actual for other projects

alisevych avatar Aug 01 '23 15:08 alisevych