Create dmf test module (#493)
* Add DMF parent module + submodules Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Fix sonar issue Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Refactor Test Module Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * - Fix tenant is empty - Small refactoring Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Remove org.springframework.context.annotation.Description Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Configure rabbit test template Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Fix header Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * tenant should not be empty Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Increase time out Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Increase 3 to sec. Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Fix comments Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Add port Signed-off-by: SirWayne <dennis.melzer@bosch-si.com> * Fix test config Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -13,13 +13,13 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwtmockito.GwtMockitoTestRunner;
|
||||
import com.vaadin.client.UIDL;
|
||||
import com.vaadin.client.ui.dd.VDragEvent;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@@ -31,25 +31,25 @@ public class ItemIdClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verifies that drag source is not valid for the configured id (strict mode)")
|
||||
public void noMatchInStrictMode() {
|
||||
ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
final ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String testId = "thisId";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
final String testId = "thisId";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
String configuredId = "component0";
|
||||
String id = "this";
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
final String configuredId = "component0";
|
||||
final String id = "this";
|
||||
when(uidl.getStringAttribute(configuredId)).thenReturn(id);
|
||||
String configuredMode = "m";
|
||||
String strictMode = "s";
|
||||
final String configuredMode = "m";
|
||||
final String strictMode = "s";
|
||||
when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
|
||||
String count = "c";
|
||||
final String count = "c";
|
||||
when(uidl.getIntAttribute(count)).thenReturn(1);
|
||||
|
||||
// act
|
||||
boolean result = cut.accept(dragEvent, uidl);
|
||||
final boolean result = cut.accept(dragEvent, uidl);
|
||||
|
||||
// verify that in strict mode: [thisId !equals this]
|
||||
assertThat(result).as("Expected: [" + id + " !equals " + testId + "].").isFalse();
|
||||
@@ -58,25 +58,25 @@ public class ItemIdClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verifies that drag source is valid for the configured id (strict mode)")
|
||||
public void matchInStrictMode() {
|
||||
ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
final ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String testId = "thisId";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
final String testId = "thisId";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
String configuredId = "component0";
|
||||
String id = "thisId";
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
final String configuredId = "component0";
|
||||
final String id = "thisId";
|
||||
when(uidl.getStringAttribute(configuredId)).thenReturn(id);
|
||||
String configuredMode = "m";
|
||||
String strictMode = "s";
|
||||
final String configuredMode = "m";
|
||||
final String strictMode = "s";
|
||||
when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
|
||||
String count = "c";
|
||||
final String count = "c";
|
||||
when(uidl.getIntAttribute(count)).thenReturn(1);
|
||||
|
||||
// act
|
||||
boolean result = cut.accept(dragEvent, uidl);
|
||||
final boolean result = cut.accept(dragEvent, uidl);
|
||||
|
||||
// verify that in strict mode: [thisId equals thisId]
|
||||
assertThat(result).as("Expected: [" + id + " equals " + testId + "].").isTrue();
|
||||
@@ -85,25 +85,25 @@ public class ItemIdClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verifies that drag source is not valid for the configured id (prefix mode)")
|
||||
public void noMatchInPrefixMode() {
|
||||
ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
final ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String testId = "thisId";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
final String testId = "thisId";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
String configuredId = "component0";
|
||||
String prefix = "any";
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
final String configuredId = "component0";
|
||||
final String prefix = "any";
|
||||
when(uidl.getStringAttribute(configuredId)).thenReturn(prefix);
|
||||
String configuredMode = "m";
|
||||
String prefixMode = "p";
|
||||
final String configuredMode = "m";
|
||||
final String prefixMode = "p";
|
||||
when(uidl.getStringAttribute(configuredMode)).thenReturn(prefixMode);
|
||||
String count = "c";
|
||||
final String count = "c";
|
||||
when(uidl.getIntAttribute(count)).thenReturn(1);
|
||||
|
||||
// act
|
||||
boolean result = cut.accept(dragEvent, uidl);
|
||||
final boolean result = cut.accept(dragEvent, uidl);
|
||||
|
||||
// verify that in strict mode: [thisId !startsWith any]
|
||||
assertThat(result).as("Expected: [" + testId + " !startsWith " + prefix + "].").isFalse();
|
||||
@@ -112,25 +112,25 @@ public class ItemIdClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verifies that drag source is valid for the configured id (prefix mode)")
|
||||
public void matchInPrefixMode() {
|
||||
ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
final ItemIdClientCriterion cut = new ItemIdClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String testId = "thisId";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
final String testId = "thisId";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
String configuredId = "component0";
|
||||
String prefix = "this";
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
final String configuredId = "component0";
|
||||
final String prefix = "this";
|
||||
when(uidl.getStringAttribute(configuredId)).thenReturn(prefix);
|
||||
String configuredMode = "m";
|
||||
String prefixMode = "p";
|
||||
final String configuredMode = "m";
|
||||
final String prefixMode = "p";
|
||||
when(uidl.getStringAttribute(configuredMode)).thenReturn(prefixMode);
|
||||
String count = "c";
|
||||
final String count = "c";
|
||||
when(uidl.getIntAttribute(count)).thenReturn(1);
|
||||
|
||||
// act
|
||||
boolean result = cut.accept(dragEvent, uidl);
|
||||
final boolean result = cut.accept(dragEvent, uidl);
|
||||
|
||||
// verify that in strict mode: [thisId startsWith this]
|
||||
assertThat(result).as("Expected: [" + testId + " startsWith " + prefix + "].").isTrue();
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.ViewCriteri
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Document;
|
||||
@@ -35,6 +34,7 @@ import com.vaadin.client.ui.VDragAndDropWrapper;
|
||||
import com.vaadin.client.ui.VScrollTable;
|
||||
import com.vaadin.client.ui.dd.VDragEvent;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@@ -47,11 +47,11 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verfies compilation of template strings.")
|
||||
public void verifyCompiledTemplateStrings() {
|
||||
ViewCriterionTemplates templates = GWT.create(ViewCriterionTemplates.class);
|
||||
final ViewCriterionTemplates templates = GWT.create(ViewCriterionTemplates.class);
|
||||
|
||||
// compile templates
|
||||
String multiSelectionStyle = templates.multiSelectionStyle("my-theme", "10").asString();
|
||||
String notificationMsg = templates.notificationMsg("some-message").asString();
|
||||
final String multiSelectionStyle = templates.multiSelectionStyle("my-theme", "10").asString();
|
||||
final String notificationMsg = templates.notificationMsg("some-message").asString();
|
||||
|
||||
// assure compilation
|
||||
assertThat(multiSelectionStyle).as("Expected: Compiled template string").isNotNull();
|
||||
@@ -61,13 +61,13 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Process serialized config for hiding the drop hints.")
|
||||
public void processSerializedDropTargetHintsConfig() {
|
||||
ViewClientCriterion cut = new ViewClientCriterion();
|
||||
final ViewClientCriterion cut = new ViewClientCriterion();
|
||||
|
||||
// prepare configuration:
|
||||
Document document = Document.get();
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final Document document = Document.get();
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getIntAttribute("cdac")).thenReturn(3);
|
||||
Element[] elements = new Element[3];
|
||||
final Element[] elements = new Element[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
when(uidl.getStringAttribute("dac" + String.valueOf(i))).thenReturn("itemId" + String.valueOf(i));
|
||||
elements[i] = Mockito.mock(Element.class);
|
||||
@@ -95,11 +95,11 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Exception occures when processing serialized config for hiding the drop hints.")
|
||||
public void exceptionWhenProcessingDropTargetHintsDataStructure() {
|
||||
ViewClientCriterion cut = new ViewClientCriterion();
|
||||
final ViewClientCriterion cut = new ViewClientCriterion();
|
||||
|
||||
// prepare configuration:
|
||||
Document document = Document.get();
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final Document document = Document.get();
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getIntAttribute("cdac")).thenReturn(2);
|
||||
when(uidl.getStringAttribute("dac0")).thenReturn("no-problem");
|
||||
when(uidl.getStringAttribute("dac1")).thenReturn("problem-bear");
|
||||
@@ -114,7 +114,7 @@ public class ViewClientCriterionTest {
|
||||
|
||||
// cross-check that problem-bear was never invoked
|
||||
verify(document, Mockito.never()).getElementById("problem-bear");
|
||||
} catch (RuntimeException re) {
|
||||
} catch (final RuntimeException re) {
|
||||
fail("Exception is not re-thrown in order to continue with the loop");
|
||||
} finally {
|
||||
reset(Document.get());
|
||||
@@ -124,12 +124,12 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Check multi row drag decoration with non-table widget")
|
||||
public void processMultiRowDragDecorationNonTable() {
|
||||
ViewClientCriterion cut = new ViewClientCriterion();
|
||||
final ViewClientCriterion cut = new ViewClientCriterion();
|
||||
|
||||
// prepare drag-event with non table widget:
|
||||
VDragAndDropWrapper nonTable = Mockito.mock(VDragAndDropWrapper.class);
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", nonTable);
|
||||
Document document = Document.get();
|
||||
final VDragAndDropWrapper nonTable = Mockito.mock(VDragAndDropWrapper.class);
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", nonTable);
|
||||
final Document document = Document.get();
|
||||
|
||||
// act
|
||||
cut.setMultiRowDragDecoration(dragEvent);
|
||||
@@ -141,18 +141,18 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Check multi row drag decoration with single selection")
|
||||
public void processMultiRowDragDecorationSingleSelection() {
|
||||
ViewClientCriterion cut = new ViewClientCriterion();
|
||||
final ViewClientCriterion cut = new ViewClientCriterion();
|
||||
|
||||
// prepare table
|
||||
VScrollTable table = Mockito.spy(new VScrollTable());
|
||||
final VScrollTable table = Mockito.spy(new VScrollTable());
|
||||
table.selectedRowKeys.add("one");
|
||||
|
||||
// prepare drag-event with table widget:
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table);
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table);
|
||||
|
||||
// prepare document
|
||||
Document document = Document.get();
|
||||
Element ele = Mockito.mock(Element.class);
|
||||
final Document document = Document.get();
|
||||
final Element ele = Mockito.mock(Element.class);
|
||||
when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);
|
||||
|
||||
try {
|
||||
@@ -172,21 +172,21 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Check multi row drag decoration with a single item dragged while a multi selection is active in table")
|
||||
public void processMultiRowDragDecorationMultiSelectionNotDragged() {
|
||||
ViewClientCriterion cut = new ViewClientCriterion();
|
||||
final ViewClientCriterion cut = new ViewClientCriterion();
|
||||
|
||||
// prepare table
|
||||
VScrollTable table = Mockito.spy(new VScrollTable());
|
||||
final VScrollTable table = Mockito.spy(new VScrollTable());
|
||||
table.selectedRowKeys.add("one");
|
||||
table.selectedRowKeys.add("two");
|
||||
table.focusedRow = Mockito.mock(VScrollTable.VScrollTableBody.VScrollTableRow.class);
|
||||
when(table.focusedRow.getKey()).thenReturn("another");
|
||||
|
||||
// prepare drag-event with table widget:
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table);
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table);
|
||||
|
||||
// prepare document
|
||||
Document document = Document.get();
|
||||
Element ele = Mockito.mock(Element.class);
|
||||
final Document document = Document.get();
|
||||
final Element ele = Mockito.mock(Element.class);
|
||||
when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);
|
||||
|
||||
try {
|
||||
@@ -206,22 +206,22 @@ public class ViewClientCriterionTest {
|
||||
@Test
|
||||
@Description("Check multi row drag decoration with a valid multi selection")
|
||||
public void processMultiRowDragDecorationMultiSelection() {
|
||||
ViewClientCriterion cut = new ViewClientCriterion();
|
||||
final ViewClientCriterion cut = new ViewClientCriterion();
|
||||
|
||||
// prepare table
|
||||
VScrollTable table = Mockito.spy(new VScrollTable());
|
||||
final VScrollTable table = Mockito.spy(new VScrollTable());
|
||||
table.selectedRowKeys.add("one");
|
||||
table.selectedRowKeys.add("two");
|
||||
table.focusedRow = Mockito.mock(VScrollTable.VScrollTableBody.VScrollTableRow.class);
|
||||
when(table.focusedRow.getKey()).thenReturn("one");
|
||||
|
||||
// prepare drag-event with table widget:
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table, "myTheme");
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table, "myTheme");
|
||||
dragEvent.getTransferable().getDragSource().getConnection().getUIConnector();
|
||||
|
||||
// prepare document
|
||||
Document document = Document.get();
|
||||
StyleElement ele = Mockito.spy(StyleElement.class);
|
||||
final Document document = Document.get();
|
||||
final StyleElement ele = Mockito.spy(StyleElement.class);
|
||||
when(ele.getTagName()).thenReturn(StyleElement.TAG);
|
||||
when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import static org.mockito.Mockito.when;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Document;
|
||||
@@ -28,6 +27,7 @@ import com.vaadin.client.ui.dd.VDragAndDropManager;
|
||||
import com.vaadin.client.ui.dd.VDragEvent;
|
||||
import com.vaadin.client.ui.dd.VDropHandler;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@@ -39,13 +39,13 @@ public class ViewComponentClientCriterionTest {
|
||||
@Test
|
||||
@Description("Process serialized data structure for preparing the drop targets to show.")
|
||||
public void processSerializedDropTargetHintsDataStructure() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare configuration:
|
||||
Document document = Document.get();
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final Document document = Document.get();
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getIntAttribute("cda")).thenReturn(3);
|
||||
Element[] elements = new Element[3];
|
||||
final Element[] elements = new Element[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
when(uidl.getStringAttribute("da" + String.valueOf(i))).thenReturn("itemId" + String.valueOf(i));
|
||||
elements[i] = Mockito.mock(Element.class);
|
||||
@@ -69,11 +69,11 @@ public class ViewComponentClientCriterionTest {
|
||||
@Test
|
||||
@Description("Exception occures when processing serialized data structure for preparing the drop targets to show.")
|
||||
public void exceptionWhenProcessingDropTargetHintsDataStructure() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare configuration:
|
||||
Document document = Document.get();
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final Document document = Document.get();
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getIntAttribute("cda")).thenReturn(2);
|
||||
when(uidl.getStringAttribute("da0")).thenReturn("no-problem");
|
||||
when(uidl.getStringAttribute("da1")).thenReturn("problem-bear");
|
||||
@@ -82,7 +82,7 @@ public class ViewComponentClientCriterionTest {
|
||||
// act
|
||||
try {
|
||||
cut.showDropTargetHints(uidl);
|
||||
} catch (RuntimeException re) {
|
||||
} catch (final RuntimeException re) {
|
||||
fail("Exception is not re-thrown in order to continue with the loop");
|
||||
}
|
||||
|
||||
@@ -96,19 +96,19 @@ public class ViewComponentClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verifies that drag source is valid for the configured prefix")
|
||||
public void checkDragSourceWithValidId() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String prefix = "this";
|
||||
String id = "thisId";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
|
||||
final String prefix = "this";
|
||||
final String id = "thisId";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
|
||||
|
||||
// act
|
||||
boolean result = cut.isValidDragSource(dragEvent, uidl);
|
||||
final boolean result = cut.isValidDragSource(dragEvent, uidl);
|
||||
|
||||
// assure that drag source is valid: [thisId startsWith this]
|
||||
assertThat(result).as("Expected: [" + id + " startsWith " + prefix + "].").isTrue();
|
||||
@@ -117,19 +117,19 @@ public class ViewComponentClientCriterionTest {
|
||||
@Test
|
||||
@Description("Verifies that drag source is not valid for the configured prefix")
|
||||
public void checkDragSourceWithInvalidId() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String prefix = "this";
|
||||
String id = "notThis";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
|
||||
final String prefix = "this";
|
||||
final String id = "notThis";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
|
||||
|
||||
// act
|
||||
boolean result = cut.isValidDragSource(dragEvent, uidl);
|
||||
final boolean result = cut.isValidDragSource(dragEvent, uidl);
|
||||
|
||||
// assure that drag source is valid: [thisId !startsWith this]
|
||||
assertThat(result).as("Expected: [" + id + " !startsWith " + prefix + "].").isFalse();
|
||||
@@ -139,23 +139,23 @@ public class ViewComponentClientCriterionTest {
|
||||
@Description("An exception occures while the drag source is validated against the configured prefix")
|
||||
public void exceptionWhenCheckingDragSource() {
|
||||
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare drag-event:
|
||||
String prefix = "this";
|
||||
String id = "notThis";
|
||||
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
|
||||
final String prefix = "this";
|
||||
final String id = "notThis";
|
||||
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
|
||||
doThrow(new RuntimeException()).when(dragEvent).getTransferable();
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
|
||||
|
||||
// act
|
||||
Boolean result = null;
|
||||
try {
|
||||
result = cut.isValidDragSource(dragEvent, uidl);
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
fail("Exception is not re-thrown");
|
||||
}
|
||||
|
||||
@@ -166,18 +166,18 @@ public class ViewComponentClientCriterionTest {
|
||||
@Test
|
||||
@Description("Successfully checks if the current drop location is in the list of valid drop targets")
|
||||
public void successfulCheckValidDropTarget() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare drag and drop manager:
|
||||
String dtargetid = "dropTarget1Id";
|
||||
VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
|
||||
final String dtargetid = "dropTarget1Id";
|
||||
final VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
|
||||
when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = createUidlWithThreeDropTargets();
|
||||
final UIDL uidl = createUidlWithThreeDropTargets();
|
||||
|
||||
// act
|
||||
boolean result = cut.isValidDropTarget(uidl);
|
||||
final boolean result = cut.isValidDropTarget(uidl);
|
||||
|
||||
// assure drop target is valid: [dropTarget1Id startsWith dropTarget1]
|
||||
assertThat(result).as("Expected: [" + dtargetid + " startsWith dropTarget1].").isTrue();
|
||||
@@ -186,43 +186,42 @@ public class ViewComponentClientCriterionTest {
|
||||
@Test
|
||||
@Description("Failed check if the current drop location is in the list of valid drop targets")
|
||||
public void failedCheckValidDropTarget() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare drag and drop manager:
|
||||
String dtargetid = "no-hit";
|
||||
VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
|
||||
final String dtargetid = "no-hit";
|
||||
final VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
|
||||
when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = createUidlWithThreeDropTargets();
|
||||
final UIDL uidl = createUidlWithThreeDropTargets();
|
||||
|
||||
// act
|
||||
boolean result = cut.isValidDropTarget(uidl);
|
||||
final boolean result = cut.isValidDropTarget(uidl);
|
||||
|
||||
// assure "no-hit" does not match [dropTarget0,dropTarget1,dropTarget2]
|
||||
assertThat(result).as("Expected: [" + dtargetid + " does not match one of the list entries].")
|
||||
.isFalse();
|
||||
assertThat(result).as("Expected: [" + dtargetid + " does not match one of the list entries].").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("An exception occures while the current drop location is validated against the list of valid drop target prefixes")
|
||||
public void exceptionWhenCheckingValidDropTarget() {
|
||||
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
|
||||
|
||||
// prepare drag and drop manager:
|
||||
String dtargetid = "no-hit";
|
||||
VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
|
||||
final String dtargetid = "no-hit";
|
||||
final VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
|
||||
when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
|
||||
doThrow(new RuntimeException()).when(dropHandler).getConnector();
|
||||
|
||||
// prepare configuration:
|
||||
UIDL uidl = createUidlWithThreeDropTargets();
|
||||
final UIDL uidl = createUidlWithThreeDropTargets();
|
||||
|
||||
// act
|
||||
Boolean result = null;
|
||||
try {
|
||||
result = cut.isValidDropTarget(uidl);
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
fail("Exception is not re-thrown");
|
||||
}
|
||||
|
||||
@@ -231,7 +230,7 @@ public class ViewComponentClientCriterionTest {
|
||||
}
|
||||
|
||||
private UIDL createUidlWithThreeDropTargets() {
|
||||
UIDL uidl = GWT.create(UIDL.class);
|
||||
final UIDL uidl = GWT.create(UIDL.class);
|
||||
when(uidl.getIntAttribute("cdt")).thenReturn(3);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
when(uidl.getStringAttribute("dt" + String.valueOf(i))).thenReturn("dropTarget" + String.valueOf(i));
|
||||
|
||||
Reference in New Issue
Block a user