Package org.sonar.core.resource

Examples of org.sonar.core.resource.ResourceDao


  private AuthorDao dao;

  @Before
  public void setUp() {
    dao = new AuthorDao(getMyBatis(), new ResourceDao(getMyBatis(), System2.INSTANCE));
  }
View Full Code Here


  @ClassRule
  public static TestDatabase db = new TestDatabase();

  @Before
  public void before() {
    executor = new MeasureFilterExecutor(db.myBatis(), db.database(), new ResourceDao(db.myBatis(), System2.INSTANCE));
  }
View Full Code Here

  }

  @Test
  public void has_component_permission() throws Exception {
    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    String componentKey = "com.foo:Bar:BarFile.xoo";
    when(resourceDao.getRootProjectByComponentKey(componentKey)).thenReturn(new ResourceDto().setKey(componentKey));
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER)).thenReturn(newArrayList(componentKey));

    assertThat(session.hasComponentPermission(UserRole.USER, componentKey)).isTrue();
    assertThat(session.hasComponentPermission(UserRole.CODEVIEWER, componentKey)).isFalse();
    assertThat(session.hasComponentPermission(UserRole.ADMIN, componentKey)).isFalse();
View Full Code Here

  }

  @Test
  public void check_component_permission_ok() throws Exception {
    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    when(resourceDao.getRootProjectByComponentKey("com.foo:Bar:BarFile.xoo")).thenReturn(new ResourceDto().setKey("com.foo:Bar"));
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER)).thenReturn(newArrayList("com.foo:Bar"));

    session.checkComponentPermission(UserRole.USER, "com.foo:Bar:BarFile.xoo");
  }
View Full Code Here

  }

  @Test(expected = ForbiddenException.class)
  public void check_component_permission_ko() throws Exception {
    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    when(resourceDao.getRootProjectByComponentKey("com.foo:Bar:BarFile.xoo")).thenReturn(new ResourceDto().setKey("com.foo:Bar2"));
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER)).thenReturn(newArrayList("com.foo:Bar"));

    session.checkComponentPermission(UserRole.USER, "com.foo:Bar:BarFile.xoo");
  }
View Full Code Here

  }

  @Test(expected = ForbiddenException.class)
  public void check_component_permission_when_project_not_found() throws Exception {
    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    when(resourceDao.getRootProjectByComponentKey("com.foo:Bar:BarFile.xoo")).thenReturn(null);

    session.checkComponentPermission(UserRole.USER, "com.foo:Bar:BarFile.xoo");
  }
View Full Code Here

  @Before
  public void setupDbClient() {
    dbClient = new DbClient(getDatabase(), getMyBatis(),
      new ComponentDao(System2.INSTANCE),
      new IssueDao(System2.INSTANCE),
      new ResourceDao(getMyBatis(), System2.INSTANCE));
    session = dbClient.openSession(false);

    storage = new ServerIssueStorage(getMyBatis(), new FakeRuleFinder(), dbClient);
  }
View Full Code Here

  @Before
  public void createDao() {
    system2 = mock(System2.class);
    when(system2.now()).thenReturn(DateUtils.parseDate("2014-04-09").getTime());

    dao = new PurgeDao(getMyBatis(), new ResourceDao(getMyBatis(), system2), new PurgeProfiler(), system2);
  }
View Full Code Here

    session = getMyBatis().openSession(false);
    RoleDao roleDao = new RoleDao();
    UserDao userDao = new UserDao(getMyBatis());
    permissionTemplateDao = new PermissionTemplateDao(getMyBatis(), System2.INSTANCE);
    Settings settings = new Settings();
    resourceDao = new ResourceDao(getMyBatis(), system2);
    permissionFacade = new PermissionFacade(roleDao, userDao, resourceDao, permissionTemplateDao, settings);
  }
View Full Code Here

  ScanIssueStorage storage;

  @Before
  public void setUp() throws Exception {
    storage = new ScanIssueStorage(getMyBatis(), new FakeRuleFinder(), snapshotCache, new ResourceDao(getMyBatis(), System2.INSTANCE), projectTree);
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.resource.ResourceDao

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.