JavaDelegate - Unit Test

cancel
Showing results for 
Search instead for 
Did you mean: 
sanjaybandhniya
Intermediate

JavaDelegate - Unit Test

I have created service task and I am using JavaDelegate for backend process.

Process working fine.

I have created test case using alfresco-process-services-unit-testing.

Normal Way it is working fine but when I Autowire any service,It is giving error.

First it was giving error of no bean type found of EndPointService. After that I have injected that class in @Configuration, now it is giving error of no bean found  which is used inside EndPointService.

Anyone have idea how can I Mock all the required dependency?

Code : 

@Component("searchRecord")
public class SearchRecord implements JavaDelegate {

	@Autowired
	private EndpointService endPointService;
}

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SearchRecordTest {

	@Configuration
	static class ContextConfiguration {
		@Bean
		public SearchRecord searchRecord() {
			return new SearchRecord();
		}
@Bean
public EndPointService endPointServiceImpl()
{ return new EndPointServiceImpl();
} } @InjectMocks @Spy private static SearchRecord searchRecord; @Mock private DelegateExecution execution; @Before public void initMocks() { MockitoAnnotations.initMocks(this); } @Test public void test() throws Exception { } }

@cjose @openpj  Help would be appreciated.