I am trying to mock outer class but always get NullPointerException. I have class:
@Service
public class ProductService {
@Autowired
public ProductService (AutoService autoService, DocumentService documentService, TimeService timeService) {
this(autoService, documentService, batchtimeService, new History());
}
inside this class I have:
public class PublishTimeProcess implements TimeProcess<Product> {
with constructor:
public PublishTimeProcess (Calendar minTime) {
this.minTime= minTime;
}
and method:
@Override
public void startProcess(List<Product> products) {
which I would like to test.
So I mocked:
@Mock
ProductService productService;
and in @Before
method I did:
@Before
public void setUp(){
publishTimeProcess = productService. new PublishTimeProcess(minTime);
}
and then in @Test
method I just try to call publishTimeProcess.startProcess(products);
but then NPE happens because publishTimeProcess
is always null. Is there a way to mock outer class but create inner class anyway?
@Edit, forgot to mention that I don't use PowerMockito
Aucun commentaire:
Enregistrer un commentaire