Skip to content

Redundant brackets for mocks and class casts #2470

@alisevych

Description

@alisevych

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

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions