Skip to content

Commit

Permalink
mockito#3000 spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Jörg von Frantzius committed Dec 1, 2023
1 parent b6175a7 commit 593a5db
Showing 1 changed file with 54 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,63 +362,68 @@ public void testNoNpe() {
}
}


/* cannot define interface in nested test class RegressionArrayIndexOutOfBoundsExcepton ,
/* cannot define interface in nested test class RegressionArrayIndexOutOfBoundsExcepton ,
* because interface cannot be defined in a non-static inner class,
* and nested test class must be non-static in order for JUnit 5 to be able to run it */
public interface BaseRepository<E, I extends Serializable> {
E findById(I id);
E save(E entity);
}
public interface BaseRepository<E, I extends Serializable> {
E findById(I id);

E save(E entity);
}

/**
* Verify regression https://github.com/mockito/mockito/issues/3000 is fixed.
*/
@Nested
public class RegressionArrayIndexOutOfBoundsException {

public class BaseService<E, I extends Serializable> {
private BaseRepository<E, I> repository;
}

public class OneRepository implements BaseRepository<Map<String,String>,String>{
public Map<String,String> findById(String id) { return Map.of();}
public Map<String,String> save(Map<String,String> entity) {return entity;}
}

public class TwoRepository implements BaseRepository<Map<Integer,String>, String>{
public Map<Integer,String> findById(String id) { return Map.of();}
public Map<Integer,String> save(Map<Integer,String> entity) {return entity;}
}

public class One {};
public class Two implements Serializable {
private static final long serialVersionUID = 1L;
};

public class UnderTest extends BaseService<One, Two> {
private OneRepository oneRepository;
private TwoRepository twoRepository;
}


@Mock
OneRepository oneRepository;

@Mock
TwoRepository twoRepository;

@InjectMocks
UnderTest underTest = new UnderTest();


@Test
public void testNoAioobe() {
assertNotNull(oneRepository);
assertNotNull(twoRepository);
assertNotNull(underTest);
}
}

public class BaseService<E, I extends Serializable> {
private BaseRepository<E, I> repository;
}

public class OneRepository implements BaseRepository<Map<String, String>, String> {
public Map<String, String> findById(String id) {
return Map.of();
}

public Map<String, String> save(Map<String, String> entity) {
return entity;
}
}

public class TwoRepository implements BaseRepository<Map<Integer, String>, String> {
public Map<Integer, String> findById(String id) {
return Map.of();
}

public Map<Integer, String> save(Map<Integer, String> entity) {
return entity;
}
}

public class One {}
;

public class Two implements Serializable {
private static final long serialVersionUID = 1L;
}

public class UnderTest extends BaseService<One, Two> {
private OneRepository oneRepository;
private TwoRepository twoRepository;
}

@Mock OneRepository oneRepository;

@Mock TwoRepository twoRepository;

@InjectMocks UnderTest underTest = new UnderTest();

@Test
public void testNoAioobe() {
assertNotNull(oneRepository);
assertNotNull(twoRepository);
assertNotNull(underTest);
}
}
}

0 comments on commit 593a5db

Please sign in to comment.