Search code examples
javaintellij-ideajunit

Auto static import in IntelliJ


In below piece of code I have used Class name to import static methods in IntelliJ IDEA 2022 Community Edition

BDDMockito.given(employeeRepository.findByEmail(employee.getEmail()))
    .willReturn(Optional.empty());
BDDMockito.given(employeeRepository.save(employee)).willReturn(employee);

Is there any way or keyboard shortcut that can remove the class name and use static import like this:

import static org.mockito.BDDMockito.given;

given(employeeRepository.findByEmail(employee.getEmail()))
    .willReturn(Optional.empty());
given(employeeRepository.save(employee)).willReturn(employee);

I googled lot and read IntelliJ articles but could not find any solution. Any IntelliJ expert can help me here?


Solution

  • You may put caret on method name, press "Alt+Enter" and select "Add static import for ..."