Allon Mureinik has uploaded a new change for review. Change subject: core: Fix GetAllVmPoolsAttachedToUserQueryTest ......................................................................
core: Fix GetAllVmPoolsAttachedToUserQueryTest GetAllVmPoolsAttachedToUserQueryTest was broken by change-id I59346bc9f1cf6d948c4401ddbd7bb365c67b5b05 which changed the query from a user query to an admin query. This patch removes the parts of the test that are only relevant to user queries (i.e., permission filtering) so that it will only check the expected behavior. Change-Id: I5883d47c4ca074c83913449ecd80972139a7dcf2 Signed-off-by: Allon Mureinik <amure...@redhat.com> --- M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllVmPoolsAttachedToUserQueryTest.java 1 file changed, 6 insertions(+), 27 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/11413/1 diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllVmPoolsAttachedToUserQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllVmPoolsAttachedToUserQueryTest.java index b69997e..9dece20 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllVmPoolsAttachedToUserQueryTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllVmPoolsAttachedToUserQueryTest.java @@ -1,7 +1,6 @@ package org.ovirt.engine.core.bll; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -18,28 +17,12 @@ * A test class for the {@link GetAllVmPoolsAttachedToUserQuery} class. * It mocks the DAO and tests the flow of the query itself. */ -public class GetAllVmPoolsAttachedToUserQueryTest extends AbstractUserQueryTest<GetAllVmPoolsAttachedToUserParameters, GetAllVmPoolsAttachedToUserQuery<GetAllVmPoolsAttachedToUserParameters>> { +public class GetAllVmPoolsAttachedToUserQueryTest extends AbstractQueryTest<GetAllVmPoolsAttachedToUserParameters, GetAllVmPoolsAttachedToUserQuery<GetAllVmPoolsAttachedToUserParameters>> { - /** Tests that executing a query with the same user works */ - @Test - public void testQueryWithSameUser() { - assertExecuteQueryCommandResult(getUser().getUserId(), true); - } - - /** Tests that executing a query with a different user returns an empty list */ - @Test - public void testQueryWithOtherUser() { - assertExecuteQueryCommandResult(Guid.NewGuid(), false); - } - - /** Tests that executing a query with a different user works when the query is run in admin mode */ + /** Tests that executing a query returns the expected result */ @Test public void testAdminQueryWithOtherUserWithDisks() { - when(getQueryParameters().isFiltered()).thenReturn(false); - assertExecuteQueryCommandResult(Guid.NewGuid(), true); - } - - public void assertExecuteQueryCommandResult(Guid requestedUser, boolean expectedResults) { + Guid requestedUser = Guid.NewGuid(); mockQueryParameters(requestedUser); // Mock the result of the DAO @@ -49,13 +32,9 @@ @SuppressWarnings("unchecked") List<vm_pools> actualPools = (List<vm_pools>) getQuery().getQueryReturnValue().getReturnValue(); - if (!expectedResults) { - assertTrue("no VMs should have been returned", actualPools.isEmpty()); - } else { - assertEquals("wrong number of VMs returned", 1, actualPools.size()); - vm_pools actualPool = actualPools.get(0); - assertEquals("wrong VMs returned", expectedPool, actualPool); - } + assertEquals("wrong number of VMs returned", 1, actualPools.size()); + vm_pools actualPool = actualPools.get(0); + assertEquals("wrong VMs returned", expectedPool, actualPool); } /** -- To view, visit http://gerrit.ovirt.org/11413 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5883d47c4ca074c83913449ecd80972139a7dcf2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <amure...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches