Examples of findByKey()


Examples of org.apache.ambari.server.orm.dao.MetainfoDAO.findByKey()

  public void testCheckDBVersion_Invalid() throws Exception {
    MetainfoDAO metainfoDAO =  createMock(MetainfoDAO.class);
    MetainfoEntity metainfoEntity = new MetainfoEntity();
    metainfoEntity.setMetainfoName(Configuration.SERVER_VERSION_KEY);
    metainfoEntity.setMetainfoValue("0.0.0"); // Incompatible version
    expect(metainfoDAO.findByKey(Configuration.SERVER_VERSION_KEY)).
            andReturn(metainfoEntity);
    replay(metainfoDAO);
    AmbariServer ambariServer = new AmbariServer();
    ambariServer.metainfoDAO = metainfoDAO;
    ambariServer.ambariMetaInfo = ambariMetaInfo;
View Full Code Here

Examples of org.apache.ambari.server.orm.dao.MetainfoDAO.findByKey()

  public int updateMetaInfoVersion(String version) {
    int rows = 0;
    if (version != null) {
      MetainfoDAO metainfoDAO = injector.getInstance(MetainfoDAO.class);

      MetainfoEntity versionEntity = metainfoDAO.findByKey("version");

      if (versionEntity != null) {
        versionEntity.setMetainfoValue(version);
        metainfoDAO.merge(versionEntity);
      } else {
View Full Code Here

Examples of org.sonar.api.measures.MetricFinder.findByKey()

  @Before
  public void prepare() {
    activeRules = new ActiveRulesBuilder().build();
    fs = new DefaultFileSystem();
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
    when(metricFinder.findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
    sensorContext = mock(SensorContext.class);
    settings = new Settings();
    resourcePerspectives = mock(ResourcePerspectives.class);
    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
View Full Code Here

Examples of org.sonar.api.measures.MetricFinder.findByKey()

  public void prepare() {
    activeRules = new ActiveRulesBuilder().build();
    fs = new DefaultFileSystem();
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
    when(metricFinder.findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
    sensorContext = mock(SensorContext.class);
    settings = new Settings();
    resourcePerspectives = mock(ResourcePerspectives.class);
    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    BlockCache blockCache = mock(BlockCache.class);
View Full Code Here

Examples of org.sonar.api.measures.MetricFinder.findByKey()

  }

  @Test
  public void fallback_on_name_sort_when_metric_is_unknown() {
    MetricFinder finder = mock(MetricFinder.class);
    when(finder.findByKey(anyString())).thenReturn(null);
    MeasureFilterFactory factory = new MeasureFilterFactory(finder, system);
    Map<String, Object> props = ImmutableMap.<String, Object>of("sort", "metric:sqale_index");
    MeasureFilter filter = factory.create(props);

    assertThat(filter.sort().column()).isEqualTo("p.long_name");
View Full Code Here

Examples of org.sonar.api.measures.MetricFinder.findByKey()

    assertThat(conditions).isEmpty();
  }

  private MetricFinder newMetricFinder() {
    MetricFinder finder = mock(MetricFinder.class);
    when(finder.findByKey(anyString())).thenAnswer(new Answer<Metric>() {
      public Metric answer(InvocationOnMock invocationOnMock) throws Throwable {
        String key = (String) invocationOnMock.getArguments()[0];
        return new Metric.Builder(key, key, Metric.ValueType.INT).create();
      }
    });
View Full Code Here

Examples of org.sonar.api.measures.MetricFinder.findByKey()

    ResourceCache resourceCache = mock(ResourceCache.class);
    when(snapshotCache.get("foo:org/foo/Bar.java")).thenReturn(fileSnapshot);
    when(resourceCache.get("foo:org/foo/Bar.java")).thenReturn(aFile);

    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey(CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn(CoreMetrics.DUPLICATIONS_DATA.setId(2));

    duplicationPersister = new DuplicationPersister(getMyBatis(), ruleFinder, snapshotCache, resourceCache, duplicationCache, metricFinder);
  }

  @Test
View Full Code Here

Examples of org.sonar.api.measures.MetricFinder.findByKey()

  @Before
  public void createIndex() throws IOException {
    deprecatedViolations = mock(DeprecatedViolations.class);
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey("ncloc")).thenReturn(CoreMetrics.NCLOC);
    ruleFinder = mock(RuleFinder.class);

    ProjectTree projectTree = mock(ProjectTree.class);
    index = new DefaultIndex(mock(PersistenceManager.class), projectTree, metricFinder, mock(ScanGraph.class), deprecatedViolations, mock(ResourceKeyMigration.class),
      mock(MeasureCache.class));
View Full Code Here

Examples of org.sonar.api.rules.RuleFinder.findByKey()

    Rule rule1 = Rule.create("repo", "rule1");
    rule1.setId(1);
    Rule rule2 = Rule.create("repo", "rule2");
    rule2.setId(2);

    when(ruleFinder.findByKey(rule1.ruleKey())).thenReturn(rule1);
    when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2);

    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
View Full Code Here

Examples of org.sonar.api.rules.RuleFinder.findByKey()

    rule1.setId(1);
    Rule rule2 = Rule.create("repo", "rule2");
    rule2.setId(2);

    when(ruleFinder.findByKey(rule1.ruleKey())).thenReturn(rule1);
    when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2);

    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
    PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.