Search in sources :

Example 1 with ValidateExistingContainerCallback

use of org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback in project kie-wb-common by kiegroup.

the class DeploymentPopupBuilderTest method testSingleServerTemplatesValidationContainerNameDoesNotExist.

@Test
public void testSingleServerTemplatesValidationContainerNameDoesNotExist() throws Exception {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final Set<String> containers = new HashSet<String>() {

        {
            add("container1");
            add("container2");
            add("container3");
        }
    };
    doReturn(containers).when(buildExecutor).existingContainers(serverTemplate);
    final ValidateExistingContainerCallback validation = builder.singleServerTemplatesValidation(serverTemplate);
    assertFalse(validation.containerNameExists("container4"));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ValidateExistingContainerCallback

use of org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback in project kie-wb-common by kiegroup.

the class DeploymentPopupBuilderTest method testMultipleServerTemplatesValidationWhenContainerNameExists.

@Test
public void testMultipleServerTemplatesValidationWhenContainerNameExists() throws Exception {
    final List<ServerTemplate> serverTemplates = new ArrayList<ServerTemplate>() {

        {
            add(serverTemplate("serverTemplate1", "container1", "container2"));
            add(serverTemplate("serverTemplate2", "container1", "container2", "container3"));
            add(serverTemplate("serverTemplate3", "container1", "container2"));
        }
    };
    doNothing().when(popupView).addServerTemplates(any());
    doReturn("serverTemplate2").when(popupView).getServerTemplate();
    final ValidateExistingContainerCallback validation = builder.multipleServerTemplatesValidation(serverTemplates);
    assertTrue(validation.containerNameExists("container3"));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ArrayList(java.util.ArrayList) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) Test(org.junit.Test)

Example 3 with ValidateExistingContainerCallback

use of org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback in project kie-wb-common by kiegroup.

the class DeploymentPopupBuilderTest method testSingleServerTemplatesValidationContainerNameExists.

@Test
public void testSingleServerTemplatesValidationContainerNameExists() throws Exception {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final Set<String> containers = new HashSet<String>() {

        {
            add("container1");
            add("container2");
            add("container3");
        }
    };
    doReturn(containers).when(buildExecutor).existingContainers(serverTemplate);
    final ValidateExistingContainerCallback validation = builder.singleServerTemplatesValidation(serverTemplate);
    assertTrue(validation.containerNameExists("container3"));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ValidateExistingContainerCallback

use of org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback in project kie-wb-common by kiegroup.

the class DeploymentPopupBuilderTest method testBuildDeployWithMultipleServerTemplates.

@Test
public void testBuildDeployWithMultipleServerTemplates() throws Exception {
    final List<ServerTemplate> serverTemplates = new ArrayList<>();
    final ValidateExistingContainerCallback callback = mock(ValidateExistingContainerCallback.class);
    final ParameterizedCommand<DeploymentScreenPopupViewImpl> onSuccess = (v) -> {
    };
    doReturn(callback).when(builder).multipleServerTemplatesValidation(serverTemplates);
    builder.buildDeployWithMultipleServerTemplates(serverTemplates, onSuccess);
    verify(builder).setViewFields(onSuccess, callback);
}
Also used : DeploymentScreenPopupViewImpl(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) BeforeClass(org.junit.BeforeClass) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Mock(org.mockito.Mock) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) RunWith(org.junit.runner.RunWith) Set(java.util.Set) Test(org.junit.Test) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Mockito(org.mockito.Mockito) List(java.util.List) GWTMockUtilities(com.google.gwt.junit.GWTMockUtilities) DeploymentScreenPopupViewImpl(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl) Assert(org.junit.Assert) Before(org.junit.Before) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ArrayList(java.util.ArrayList) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) Test(org.junit.Test)

Example 5 with ValidateExistingContainerCallback

use of org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback in project kie-wb-common by kiegroup.

the class DeploymentPopupBuilderTest method testBuildDeployWithOneServerTemplate.

@Test
public void testBuildDeployWithOneServerTemplate() throws Exception {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final ValidateExistingContainerCallback callback = mock(ValidateExistingContainerCallback.class);
    final ParameterizedCommand<DeploymentScreenPopupViewImpl> onSuccess = (v) -> {
    };
    doReturn(callback).when(builder).singleServerTemplatesValidation(serverTemplate);
    builder.buildDeployWithOneServerTemplate(serverTemplate, onSuccess);
    verify(builder).setViewFields(onSuccess, callback);
}
Also used : DeploymentScreenPopupViewImpl(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) BeforeClass(org.junit.BeforeClass) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Mock(org.mockito.Mock) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) RunWith(org.junit.runner.RunWith) Set(java.util.Set) Test(org.junit.Test) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Mockito(org.mockito.Mockito) List(java.util.List) GWTMockUtilities(com.google.gwt.junit.GWTMockUtilities) DeploymentScreenPopupViewImpl(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl) Assert(org.junit.Assert) Before(org.junit.Before) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)6 ValidateExistingContainerCallback (org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 GWTMockUtilities (com.google.gwt.junit.GWTMockUtilities)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)2 List (java.util.List)2 Set (java.util.Set)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 RunWith (org.junit.runner.RunWith)2 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)2 DeploymentScreenPopupViewImpl (org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl)2 Mock (org.mockito.Mock)2 Mockito (org.mockito.Mockito)2 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)2