Skip to content
Snippets Groups Projects
Commit eea8248a authored by cramakri's avatar cramakri
Browse files

LMS-1342 Refactoring of tests so as not to cause warnings when running system tests.

SVN: 14388
parent 06de6e0e
No related branches found
No related tags found
No related merge requests found
...@@ -131,6 +131,14 @@ public final class UrlParamsHelper ...@@ -131,6 +131,14 @@ public final class UrlParamsHelper
setUrlParams(parseParamString(nonEmptyParameterString)); setUrlParams(parseParamString(nonEmptyParameterString));
} }
/**
* A public version of initializeUrlParamters used by a test case
*/
public final void initializeUrlParametersForTest(String nonEmptyParameterString)
{
initializeUrlParameters(nonEmptyParameterString);
}
public final IDelegatedAction getOpenInitialTabAction() public final IDelegatedAction getOpenInitialTabAction()
{ {
return new OpenInitialTabAction(); return new OpenInitialTabAction();
...@@ -138,9 +146,9 @@ public final class UrlParamsHelper ...@@ -138,9 +146,9 @@ public final class UrlParamsHelper
/** /**
* An action that opens the initial tab specified by the URL parameters. This class is given * An action that opens the initial tab specified by the URL parameters. This class is given
* package visibility so it can be used by a test. * public visibility so it can be used by a test.
*/ */
class OpenInitialTabAction implements IDelegatedAction public class OpenInitialTabAction implements IDelegatedAction
{ {
public void execute() public void execute()
...@@ -164,10 +172,9 @@ public final class UrlParamsHelper ...@@ -164,10 +172,9 @@ public final class UrlParamsHelper
} }
/** /**
* Opens an initial tab if a parameter is specified in URL. Given package visibility so it * Opens an initial tab if a parameter is specified in URL.
* can be used by a test.
*/ */
void openInitialTabUnderExceptionHandler() throws UserFailureException private void openInitialTabUnderExceptionHandler() throws UserFailureException
{ {
// If a permlink has been specified, open a viewer on the specified object // If a permlink has been specified, open a viewer on the specified object
String entityKindValueOrNull = String entityKindValueOrNull =
...@@ -191,6 +198,14 @@ public final class UrlParamsHelper ...@@ -191,6 +198,14 @@ public final class UrlParamsHelper
} }
} }
/**
* A public version of openInitialTabUnderExceptionHandler() used by the test case.
*/
public void openInitialTabUnderExceptionHandlerForTest() throws UserFailureException
{
openInitialTabUnderExceptionHandler();
}
/** /**
* Open the entity details tab for the specified entity kind and permId. * Open the entity details tab for the specified entity kind and permId.
*/ */
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package ch.systemsx.cisd.openbis.generic.client.web.client.application; package ch.systemsx.cisd.openbis.generic.client.web.clientnonjs;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.Mockery; import org.jmock.Mockery;
...@@ -24,6 +24,9 @@ import org.testng.annotations.BeforeMethod; ...@@ -24,6 +24,9 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.UrlParamsHelper;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.UrlParamsHelper.OpenInitialTabAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.UrlParamsHelper.OpenInitialTabAction;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria;
...@@ -76,7 +79,7 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -76,7 +79,7 @@ public class UrlParamsHelperTest extends AssertJUnit
}); });
final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("entity=SAMPLE&permId=20100104150239401-871"); urlParamsHelper.initializeUrlParametersForTest("entity=SAMPLE&permId=20100104150239401-871");
IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction(); IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction();
action.execute(); action.execute();
...@@ -102,12 +105,12 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -102,12 +105,12 @@ public class UrlParamsHelperTest extends AssertJUnit
// No permId supplied // No permId supplied
urlParamsHelper = new UrlParamsHelper(viewContext); urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("entity=SAMPLE"); urlParamsHelper.initializeUrlParametersForTest("entity=SAMPLE");
action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction();
try try
{ {
action.openInitialTabUnderExceptionHandler(); action.openInitialTabUnderExceptionHandlerForTest();
fail("A URL with no permId should result in an exception."); fail("A URL with no permId should result in an exception.");
} catch (UserFailureException expected) } catch (UserFailureException expected)
{ {
...@@ -116,12 +119,12 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -116,12 +119,12 @@ public class UrlParamsHelperTest extends AssertJUnit
// No entity supplied // No entity supplied
urlParamsHelper = new UrlParamsHelper(viewContext); urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("permId=20100104150239401-871"); urlParamsHelper.initializeUrlParametersForTest("permId=20100104150239401-871");
action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction();
try try
{ {
action.openInitialTabUnderExceptionHandler(); action.openInitialTabUnderExceptionHandlerForTest();
fail("A URL with no entity should result in an exception."); fail("A URL with no entity should result in an exception.");
} catch (UserFailureException expected) } catch (UserFailureException expected)
{ {
...@@ -147,12 +150,12 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -147,12 +150,12 @@ public class UrlParamsHelperTest extends AssertJUnit
UrlParamsHelper.OpenInitialTabAction action; UrlParamsHelper.OpenInitialTabAction action;
urlParamsHelper = new UrlParamsHelper(viewContext); urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("entity=JUNK"); urlParamsHelper.initializeUrlParametersForTest("entity=JUNK");
action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction();
try try
{ {
action.openInitialTabUnderExceptionHandler(); action.openInitialTabUnderExceptionHandlerForTest();
fail("A URL with invalid entity should result in an exception."); fail("A URL with invalid entity should result in an exception.");
} catch (UserFailureException expected) } catch (UserFailureException expected)
{ {
...@@ -180,7 +183,7 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -180,7 +183,7 @@ public class UrlParamsHelperTest extends AssertJUnit
}); });
final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("searchEntity=SAMPLE&code=CL1"); urlParamsHelper.initializeUrlParametersForTest("searchEntity=SAMPLE&code=CL1");
IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction(); IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction();
action.execute(); action.execute();
...@@ -206,7 +209,7 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -206,7 +209,7 @@ public class UrlParamsHelperTest extends AssertJUnit
}); });
final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("searchEntity=SAMPLE"); urlParamsHelper.initializeUrlParametersForTest("searchEntity=SAMPLE");
IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction(); IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction();
action.execute(); action.execute();
...@@ -227,14 +230,14 @@ public class UrlParamsHelperTest extends AssertJUnit ...@@ -227,14 +230,14 @@ public class UrlParamsHelperTest extends AssertJUnit
}); });
final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext);
urlParamsHelper.initializeUrlParameters("searchEntity=DATA_SET"); urlParamsHelper.initializeUrlParametersForTest("searchEntity=DATA_SET");
OpenInitialTabAction action = OpenInitialTabAction action =
(OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction();
try try
{ {
action.openInitialTabUnderExceptionHandler(); action.openInitialTabUnderExceptionHandlerForTest();
fail("Only SAMPLE is supported by the search link mechanism right now."); fail("Only SAMPLE is supported by the search link mechanism right now.");
} catch (UserFailureException expected) } catch (UserFailureException expected)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment