use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.UpdateRecipesV4Response in project cloudbreak by hortonworks.
the class UpdateRecipeServiceTest method testRefreshRecipesForClusterAttachAndDetach.
@Test
public void testRefreshRecipesForClusterAttachAndDetach() {
// GIVEN
Map<String, Set<String>> sampleMap = new HashMap<>();
sampleMap.put(MASTER_HOST_GROUP_NAME, new HashSet<>());
sampleMap.put(GATEWAY_HOST_GROUP_NAME, Set.of(PRE_CLDR_START_RECIPE));
Map<String, Set<String>> hostGroupsSample = new HashMap<>();
hostGroupsSample.put(MASTER_HOST_GROUP_NAME, Set.of(POST_CLDR_START_RECIPE));
hostGroupsSample.put(GATEWAY_HOST_GROUP_NAME, new HashSet<>());
when(recipeService.getByNamesForWorkspaceId(anySet(), anyLong())).thenReturn(createRecipes(Set.of(PRE_CLDR_START_RECIPE, POST_CLDR_START_RECIPE)));
when(hostGroupService.getByClusterWithRecipes(anyLong())).thenReturn(createHostGroupWithRecipes(hostGroupsSample));
// WHEN
UpdateRecipesV4Response response = underTest.refreshRecipesForCluster(DUMMY_ID, createStack(), createUpdateHostGroupRecipes(sampleMap));
// THEN
assertTrue(response.getRecipesAttached().get(0).getRecipeNames().contains(PRE_CLDR_START_RECIPE));
assertTrue(response.getRecipesDetached().get(0).getRecipeNames().contains(POST_CLDR_START_RECIPE));
}
Aggregations