@Before public void setup() { chefClientAsyncManager = new ChefClientAsyncManagerImpl(); chefClientAsyncManager.setChefClientManager(chefCientManager); chefClientAsyncManager.setTaskNotificator(taskNotificator); chefClientAsyncManager.setPropertiesProvider(propertiesProvider); chefClientAsyncManager.setTaskManager(taskManager); }
@Test public void shouldDelete() throws ChefClientExecutionException { // given String vdc = "virtualDataCenter"; String chefClientName = "chefClientNames"; Task task = new Task(); String callback = "http://callback"; // when when(propertiesProvider.getProperty(SystemPropertiesProvider.CHEF_NODE_BASE_URL)) .thenReturn("http://baseurl"); chefClientAsyncManager.chefClientDelete(vdc, chefClientName, task, callback); // then verify(chefCientManager).chefClientDelete(vdc, chefClientName); verify(taskManager).updateTask(task); }
@Test public void shouldUpdateErrorTaskWhenDeleteAndChefClientExecutionError() throws ChefClientExecutionException { // given String vdc = "virtualDataCenter"; String chefClientName = "chefClientNames"; Task task = new Task(); String callback = "http://callback"; // when when(propertiesProvider.getProperty(SystemPropertiesProvider.CHEF_NODE_BASE_URL)) .thenReturn("http://baseurl"); doThrow(new ChefClientExecutionException("error")) .when(chefCientManager) .chefClientDelete(vdc, chefClientName); chefClientAsyncManager.chefClientDelete(vdc, chefClientName, task, callback); // then assertEquals(task.getStatus(), Task.TaskStates.ERROR); verify(chefCientManager).chefClientDelete(vdc, chefClientName); verify(taskManager).updateTask(task); }