I followed what @hoaz suggested. However, I am getting nullpointer exception
@RunWith(MockitoJUnitRunner.class) public class GeneralConfigServiceImplTest {
You haven't mocked the behavior of getId in externalDependencyObject therefore it is returning null and giving you the NPE when toString() is called on that null.
getId
externalDependencyObject
null
toString()
You need a when(externalDependencyObject.getId()).then...
when(externalDependencyObject.getId()).then...