@Test public void getOriginal_returns_original() { assertThat(new Duplication(SOME_ORIGINAL_TEXTBLOCK, ImmutableSet.of(mock(Duplicate.class))).getOriginal()).isSameAs(SOME_ORIGINAL_TEXTBLOCK); }
@Test public void delegatesCreateLargerBetterDoubleGaugeToStatisticsManager() { StatisticDescriptor descriptorReturnedByManager = mock(StatisticDescriptor.class); when(statisticsManager .createDoubleGauge(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS, false)) .thenReturn(descriptorReturnedByManager); StatisticDescriptor result = internalDistributedSystem .createDoubleGauge(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS, false); assertThat(result) .isSameAs(descriptorReturnedByManager); }
@Test public void delegatesCreateLongCounterToStatisticsManager() { StatisticDescriptor descriptorReturnedByManager = mock(StatisticDescriptor.class); when(statisticsManager .createLongCounter(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS)) .thenReturn(descriptorReturnedByManager); StatisticDescriptor result = internalDistributedSystem .createLongCounter(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS); assertThat(result) .isSameAs(descriptorReturnedByManager); }
@Test public void delegatesCreateIntGaugeToStatisticsManager() { StatisticDescriptor descriptorReturnedByManager = mock(StatisticDescriptor.class); when(statisticsManager .createIntGauge(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS)) .thenReturn(descriptorReturnedByManager); StatisticDescriptor result = internalDistributedSystem .createIntGauge(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS); assertThat(result) .isSameAs(descriptorReturnedByManager); }
@Test public void delegatesCreateLongGaugeToStatisticsManager() { StatisticDescriptor descriptorReturnedByManager = mock(StatisticDescriptor.class); when(statisticsManager.createLongGauge(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS)) .thenReturn(descriptorReturnedByManager); StatisticDescriptor result = internalDistributedSystem .createLongGauge(STATISTIC_NAME, STATISTIC_DESCRIPTION, STATISTIC_UNITS); assertThat(result) .isSameAs(descriptorReturnedByManager); }
@Test public void destroyMappingGivenARegionPathReturnsTheNoSlashRegionNameAsTheConfigObject() { results.add(successFunctionResult); ResultModel result = destroyRegionMappingCommand.destroyMapping("/" + regionName); verify(destroyRegionMappingCommand, times(1)).executeAndGetFunctionResult(any(), eq(regionName), any()); assertThat(result.getStatus()).isSameAs(Result.Status.OK); assertThat(result.getConfigObject()).isEqualTo(regionName); }
@Test public void getLevel_returns_object_passed_in_constructor() { assertThat(new EvaluatedCondition(SOME_CONDITION, SOME_LEVEL, SOME_VALUE).getLevel()).isSameAs(SOME_LEVEL); }
@Test public void verify_getters() { String error = "error threshold"; Condition condition = new Condition(SOME_METRIC, SOME_OPERATOR, error); assertThat(condition.getMetric()).isSameAs(SOME_METRIC); assertThat(condition.getOperator()).isSameAs(Condition.Operator.LESS_THAN); assertThat(condition.getErrorThreshold()).isEqualTo(error); }
@Test public void createsMappingReturnsStatusERRORWhenClusterConfigIsDisabled() { results.add(successFunctionResult); doReturn(null).when(createRegionMappingCommand).getConfigurationPersistenceService(); ResultModel result = createRegionMappingCommand.createMapping(regionName, dataSourceName, tableName, pdxClass, false, null, null, null); assertThat(result.getStatus()).isSameAs(Result.Status.ERROR); assertThat(result.toString()).contains("Cluster Configuration must be enabled."); }
@Test public void getTextBlock_returns_TextBlock_constructor_argument() { TextBlock textBlock = new TextBlock(2, 3); assertThat(new InnerDuplicate(textBlock).getTextBlock()).isSameAs(textBlock); }
@Test public void getTextBlock_returns_TextBlock_constructor_argument() { TextBlock textBlock = new TextBlock(2, 3); assertThat(new CrossProjectDuplicate(FILE_KEY_1, textBlock).getTextBlock()).isSameAs(textBlock); }
@Test public void getTextBlock_returns_TextBlock_constructor_argument() { TextBlock textBlock = new TextBlock(2, 3); assertThat(new InProjectDuplicate(FILE_1, textBlock).getTextBlock()).isSameAs(textBlock); }
@Test public void rule_key_can_contain_colons() { RuleKey ruleKey = RuleKey.of("squid", "Key:With:Some::Colons"); QProfileDto profile = newQualityProfileDto(); ActiveRuleKey key = ActiveRuleKey.of(profile, ruleKey); assertThat(key.getRuleProfileUuid()).isEqualTo(profile.getRulesProfileUuid()); assertThat(key.getRuleKey()).isSameAs(ruleKey); assertThat(key.toString()).isEqualTo(profile.getRulesProfileUuid() + ":squid:Key:With:Some::Colons"); }
@Test public void apply() { Comparable<?> value = mock(Comparable.class); Condition condition = mock(Condition.class); QualityGateMeasuresStep.MetricEvaluationResult original = new QualityGateMeasuresStep.MetricEvaluationResult( new EvaluationResult(Measure.Level.ERROR, value), condition); QualityGateMeasuresStep.MetricEvaluationResult modified = underTest.apply(original); assertThat(modified.evaluationResult.getLevel()).isSameAs(OK); assertThat(modified.evaluationResult.getValue()).isSameAs(value); assertThat(modified.condition).isSameAs(condition); }
@Test public void of() { RuleKey ruleKey = RuleKey.of("xoo", "R1"); QProfileDto profile = newQualityProfileDto(); ActiveRuleKey key = ActiveRuleKey.of(profile, ruleKey); assertThat(key.getRuleProfileUuid()).isEqualTo(profile.getRulesProfileUuid()); assertThat(key.getRuleKey()).isSameAs(ruleKey); assertThat(key.toString()).isEqualTo(profile.getRulesProfileUuid() + ":xoo:R1"); }
@Test public void install_and_load_plugins() { PluginInfo info = new PluginInfo("squid"); ImmutableMap<String, ScannerPlugin> plugins = ImmutableMap.of("squid", new ScannerPlugin("squid", 1L, info)); Plugin instance = mock(Plugin.class); when(loader.load(anyMap())).thenReturn(ImmutableMap.of("squid", instance)); when(installer.installRemotes()).thenReturn(plugins); underTest.start(); assertThat(underTest.getPluginInfos()).containsOnly(info); assertThat(underTest.getPluginsByKey()).isEqualTo(plugins); assertThat(underTest.getPluginInfo("squid")).isSameAs(info); assertThat(underTest.getPluginInstance("squid")).isSameAs(instance); underTest.stop(); verify(loader).unload(anyCollection()); }
@Test public void generatesWithEvictionMaxEntry() { evictionAction = EvictionAction.OVERFLOW_TO_DISK.toString(); evictionEntryCount = 1; generate(); RegionAttributesType.EvictionAttributes evictionAttributes = config.getRegionAttributes().getEvictionAttributes(); assertThat(evictionAttributes).isNotNull(); assertThat(evictionAttributes.getLruEntryCount().getAction()) .isSameAs(EnumActionDestroyOverflow.OVERFLOW_TO_DISK); assertThat(evictionAttributes.getLruEntryCount().getMaximum()).isEqualTo("1"); }
@Test public void add_plugin_to_list_of_installed_plugins() throws IOException { File jar = touch(temp.newFolder(), "sonar-foo-plugin.jar"); PluginInfo info = new PluginInfo("foo"); PluginFileSystem underTest = new PluginFileSystem(settings.asConfig()); underTest.addInstalledPlugin(info, jar); assertThat(underTest.getInstalledFiles()).hasSize(1); InstalledPlugin installedPlugin = underTest.getInstalledPlugin("foo").get(); assertThat(installedPlugin.getCompressedJar()).isNull(); assertThat(installedPlugin.getLoadedJar().getFile().toPath()).isEqualTo(jar.toPath()); assertThat(installedPlugin.getPluginInfo()).isSameAs(info); }
@Test public void trace_logs() { logTester.setLevel(LoggerLevel.TRACE); IndexResponse response = es.client().prepareIndex(FakeIndexDefinition.INDEX_TYPE_FAKE) .setSource(FakeIndexDefinition.newDoc(42).getFields()) .get(); assertThat(response.getResult()).isSameAs(Result.CREATED); assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); }
@Test public void index_with_index_type_and_id() { IndexResponse response = es.client().prepareIndex(FakeIndexDefinition.INDEX_TYPE_FAKE) .setSource(FakeIndexDefinition.newDoc(42).getFields()) .get(); assertThat(response.getResult()).isSameAs(Result.CREATED); }