Search in sources :

Example 6 with UpdateRecipesV4Response

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));
}
Also used : ArgumentMatchers.anySet(org.mockito.ArgumentMatchers.anySet) HashSet(java.util.HashSet) Set(java.util.Set) UpdateRecipesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.UpdateRecipesV4Response) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateRecipesV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.UpdateRecipesV4Response)6 HashSet (java.util.HashSet)5 Set (java.util.Set)5 HashMap (java.util.HashMap)4 Test (org.junit.jupiter.api.Test)4 ArgumentMatchers.anySet (org.mockito.ArgumentMatchers.anySet)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)2 Joiner (com.google.common.base.Joiner)1 UpdateHostGroupRecipes (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.UpdateHostGroupRecipes)1 AttachRecipeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.AttachRecipeV4Response)1 DetachRecipeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.DetachRecipeV4Response)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 GeneratedRecipe (com.sequenceiq.cloudbreak.domain.stack.cluster.host.GeneratedRecipe)1 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)1 List (java.util.List)1 Map (java.util.Map)1