@Before
  public void setUp() throws Exception {
    final MockProviderAccessor mpa = new MockProviderAccessor();
    user = new User("test", mpa, new MockCrowdService());
    permissionManagerMock = new Mock(PermissionManager.class);
    permissionManagerMock.setStrict(true);

    projectManagerMock = new Mock(ProjectManager.class);
    projectManagerMock.setStrict(true);

    projectRoleManagerMock = new Mock(ProjectRoleManager.class);
    projectRoleManagerMock.setStrict(true);
  }
Ejemplo n.º 2
0
 public void testDoExecute() throws Exception {
   MockHttpServletResponse response =
       JiraTestUtil.setupExpectedRedirect("ViewFieldLayoutSchemes.jspa");
   Mock mockFieldLayoutShceme = new Mock(FieldLayoutScheme.class);
   mockFieldLayoutShceme.setStrict(true);
   String name = "some name";
   mockFieldLayoutShceme.expectVoid("setName", P.args(new IsEqual(name)));
   String description = "Test Description";
   mockFieldLayoutShceme.expectVoid("setDescription", P.args(new IsEqual(description)));
   mockFieldLayoutShceme.expectVoid("store");
   Long id = new Long(1);
   mockFieldLayoutShceme.expectAndReturn("getId", id);
   FieldLayoutScheme fieldLayoutScheme = (FieldLayoutScheme) mockFieldLayoutShceme.proxy();
   mockFieldLayoutManager.expectAndReturn(
       "getFieldLayoutSchemes", EasyList.build(fieldLayoutScheme));
   mockFieldLayoutManager.expectAndReturn(
       "getMutableFieldLayoutScheme", P.args(new IsEqual(id)), fieldLayoutScheme);
   efls.setFieldLayoutSchemeName(name);
   efls.setFieldLayoutSchemeDescription(description);
   efls.setId(id);
   assertEquals(Action.NONE, efls.execute());
   response.verify();
   mockFieldLayoutShceme.verify();
   mockFieldLayoutManager.verify();
 }
Ejemplo n.º 3
0
 public void testDoDefault() throws Exception {
   Long id = new Long(1);
   Mock mockFieldLayoutScheme = new Mock(FieldLayoutScheme.class);
   mockFieldLayoutScheme.setStrict(true);
   String name = "Test Name";
   mockFieldLayoutScheme.expectAndReturn("getName", name);
   String description = "Test Description";
   mockFieldLayoutScheme.expectAndReturn("getDescription", description);
   mockFieldLayoutManager.expectAndReturn(
       "getMutableFieldLayoutScheme", P.args(new IsEqual(id)), mockFieldLayoutScheme.proxy());
   efls.setId(id);
   assertEquals(Action.INPUT, efls.doDefault());
   assertEquals(name, efls.getFieldLayoutSchemeName());
   assertEquals(description, efls.getFieldLayoutSchemeDescription());
   mockFieldLayoutScheme.verify();
   mockFieldLayoutManager.verify();
 }
Ejemplo n.º 4
0
 public void testDoValidationDuplicateName() throws Exception {
   Mock mockFieldLayoutShceme = new Mock(FieldLayoutScheme.class);
   mockFieldLayoutShceme.setStrict(true);
   String name = "some name";
   mockFieldLayoutShceme.expectAndReturn("getName", name);
   // Return a different id to cause an error
   mockFieldLayoutShceme.expectAndReturn("getId", new Long(2));
   Long id = new Long(1);
   FieldLayoutScheme fieldLayoutScheme = (FieldLayoutScheme) mockFieldLayoutShceme.proxy();
   mockFieldLayoutManager.expectAndReturn(
       "getFieldLayoutSchemes", EasyList.build(fieldLayoutScheme));
   efls.setFieldLayoutSchemeName(name);
   efls.setId(id);
   assertEquals(Action.INPUT, efls.execute());
   assertEquals(1, efls.getErrors().size());
   assertEquals(
       "A field configuration scheme with this name already exists.",
       efls.getErrors().get("fieldLayoutSchemeName"));
   mockFieldLayoutShceme.verify();
   mockFieldLayoutManager.verify();
 }
Ejemplo n.º 5
0
 protected void setUp() throws Exception {
   super.setUp();
   mockFieldLayoutManager = new Mock(FieldLayoutManager.class);
   mockFieldLayoutManager.setStrict(true);
   efls = new EditFieldLayoutScheme((FieldLayoutManager) mockFieldLayoutManager.proxy());
 }