Vojtech Szocs has submitted this change and it was merged.
Change subject: webadmin,userportal: JUnit rule for testing UiCommon models
......................................................................
webadmin,userportal: JUnit rule for testing UiCommon models
This patch adds a JUnit TestRule used to set up the necessary
UiCommon infrastructure in order to test individual UiCommon
models.
This TestRule ensures that hidden expectations of UiCommon
models (represented by static method calls) are satisfied and
provides a 'Mocks' interface for stubbing the infrastructure
behavior, if necessary.
Example - UiCommon infrastructure setup per test class:
public class MyTest {
@ClassRule
public static UiCommonSetup setup = new UiCommonSetup();
// This is optional, but often necessary
@BeforeClass
public static void stubUiCommonInfra() {
AsyncDataProvider adp = setup.getMocks().asyncDataProvider();
when(adp.isWindowsOsType(anyInt())).thenReturn(true);
}
// Actual test code to exercise model instance(s)
}
Example - UiCommon infrastructure setup per test method:
public class MyTest {
@Rule
public UiCommonSetup setup = new UiCommonSetup();
// This is optional, but often necessary
@Before
public void stubUiCommonInfra() {
AsyncDataProvider adp = setup.getMocks().asyncDataProvider();
when(adp.isWindowsOsType(anyInt())).thenReturn(true);
}
// Actual test code to exercise model instance(s)
}
Existing test code was modified to utilize UiCommonSetup rule.
Change-Id: Ifca6bf6a6b77813fa90f419ccfe2ef9f2cd09561
Signed-off-by: Vojtech Szocs <vszocs(a)redhat.com>
---
A
frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/junit/UiCommonSetup.java
M
frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/vms/BaseVmModelBehaviorTest.java
M
frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/vms/BaseVmTest.java
3 files changed, 173 insertions(+), 39 deletions(-)
Approvals:
Alexander Wels: Looks good to me, approved
Allon Mureinik: Verified
Vojtech Szocs: Verified; Looks good to me, approved
--
To view, visit
http://gerrit.ovirt.org/31021
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifca6bf6a6b77813fa90f419ccfe2ef9f2cd09561
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vojtech Szocs <vszocs(a)redhat.com>
Gerrit-Reviewer: Alexander Wels <awels(a)redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini(a)redhat.com>
Gerrit-Reviewer: Einav Cohen <ecohen(a)redhat.com>
Gerrit-Reviewer: Frank Kobzik <fkobzik(a)redhat.com>
Gerrit-Reviewer: Gilad Chaplik <gchaplik(a)redhat.com>
Gerrit-Reviewer: Lior Vernia <lvernia(a)redhat.com>
Gerrit-Reviewer: Martin Betak <mbetak(a)redhat.com>
Gerrit-Reviewer: Tomas Jelinek <tjelinek(a)redhat.com>
Gerrit-Reviewer: Vojtech Szocs <vszocs(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server