@Test
public void registerTemplatesIfNeededTestCatchException() throws Exception {

    configureWithOneHypervisorType(new ConsolidationAlgorithmBase(), true, false);
    Mockito.doThrow(Exception.class).when(templateService).registerTemplate(Mockito.any(RegisterTemplateCmd.class));
    spy.logger = Mockito.mock(Logger.class);
    spy.registerTemplatesIfNeeded();
    verifyRegisterTemplatesIfNeededCalledMethods(0, 1, 1, 1);
    String exceptionMessage = "Error while registering a Autonomiccs system vm. ";
    Mockito.verify(spy.logger).error(Mockito.eq(exceptionMessage), Mockito.any(Exception.class));
}