Consider the following method:
public boolean isACertainValue() { if(context.getValueA() != null && context.getValueA().toBoolean() == true) {
This code is correct:
Mockito.when(contextMock.getType()).thenReturn(ContextType.certainType);
But you are getting NullPointerException because you didn't define the Mocking value that should be defines, well I'm using Spring, in my context file when I define @Autowired bean I define it this way:
@Autowired