use of hudson.security.AuthorizationMatrixProperty in project hudson-2.x by hudson.
the class FreeStyleProjectTest method testOnCreatedFromScratch.
@Test
public void testOnCreatedFromScratch() {
Hudson hudson = createMock(Hudson.class);
AuthorizationStrategy authorizationStrategy = createMock(ProjectMatrixAuthorizationStrategy.class);
expect(hudson.getAuthorizationStrategy()).andReturn(authorizationStrategy);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
User user = createMock(User.class);
expect(user.getId()).andReturn(USER).times(2);
mockStatic(User.class);
expect(User.current()).andReturn(user);
replayAll();
FreeStyleProject freeStyleProject = new FreeStyleProjectMock("testJob");
freeStyleProject.onCreatedFromScratch();
verifyAll();
assertNotNull(freeStyleProject.getCreationTime());
assertEquals(freeStyleProject.getCreatedBy(), USER);
List properties = freeStyleProject.getAllProperties();
assertEquals(properties.size(), 1);
AuthorizationMatrixProperty property = (AuthorizationMatrixProperty) properties.get(0);
assertEquals(property.getGrantedPermissions().keySet().size(), 7);
assertNotNull(property.getGrantedPermissions().get(Item.CONFIGURE));
assertTrue(property.getGrantedPermissions().get(Item.CONFIGURE).contains(USER));
}
Aggregations