<commit_before>/* 
* OpenSpeedMonitor (OSM)
* Copyright 2014 iteratec GmbH
* 
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
* 	http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*/

package de.iteratec.osm.report.external

import de.iteratec.osm.InMemoryConfigService
import de.iteratec.osm.batch.BatchActivity
import de.iteratec.osm.batch.BatchActivityService
import de.iteratec.osm.util.ServiceMocker
import groovy.mock.interceptor.MockFor

import static org.junit.Assert.assertEquals

import grails.test.mixin.*
import grails.test.mixin.support.*

import org.joda.time.DateTime
import de.iteratec.osm.report.chart.CsiAggregationUtilService
import de.iteratec.osm.measurement.schedule.JobGroup
import de.iteratec.osm.measurement.schedule.dao.JobGroupDaoService

import de.iteratec.osm.csi.Page
import de.iteratec.osm.ConfigService
import de.iteratec.osm.OsmConfiguration
import de.iteratec.osm.report.chart.AggregatorType
import de.iteratec.osm.report.chart.MeasurandGroup
import de.iteratec.osm.report.chart.CsiAggregation
import de.iteratec.osm.report.chart.CsiAggregationInterval
import de.iteratec.osm.report.external.provider.GraphiteSocketProvider
import de.iteratec.osm.csi.EventCsiAggregationService
import de.iteratec.osm.csi.PageCsiAggregationService
import de.iteratec.osm.csi.ShopCsiAggregationService
import de.iteratec.osm.result.CachedView
import de.iteratec.osm.result.EventResult
import de.iteratec.osm.result.MeasuredEvent
import de.iteratec.osm.result.CsiAggregationTagService
import de.iteratec.osm.result.MvQueryParams
import de.iteratec.osm.result.ResultCsiAggregationService
import de.iteratec.osm.measurement.environment.Browser
import de.iteratec.osm.measurement.environment.Location
import de.iteratec.osm.util.I18nService

/**
 * See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
 */
@TestFor(MetricReportingService)
@TestMixin(GrailsUnitTestMixin)
@Mock([EventResult, AggregatorType,JobGroup, BatchActivity, GraphiteServer, GraphitePath, CsiAggregationInterval, Page, MeasuredEvent, Browser, Location, OsmConfiguration])
class MetricReportingServiceTests {
	MetricReportingService serviceUnderTest
	static final double DELTA = 1e-15
	static final DateTime REPORTING_TIMESTAMP = new DateTime(2014,1,22,13,42,0)
	static final DateTime REPORTING_TIMESTAMP_START_OF_DAY = new DateTime(2014,1,22,0,0,0)
	static final DateTime REPORTING_TIMESTAMP_START_OF_WEEK = new DateTime(2014,1,20,0,0,0)
	static final String GRAPHITE_PREFIX = 'my.test.graphite.prefix'
	static final String PAGE_HP_NAME = 'HP'
	static final String SYSTEM_NAME = 'live'
	static final String SYSTEM_NAME_WITH_WHITESPACES = 'live mdot'
	static final String SYSTEM_NAME_WITH_WHITESPACES_REPLACED = 'live_mdot'
	static final String SYSTEM_NAME_WITH_DOTS = 'm.my-shop.com'
	static final String SYSTEM_NAME_WITH_DOTS_REPLACED = 'm_my-shop_com'
	static final String SYSTEM_NAME_WITH_DOTS_AND_WHITESPACES = 'live m.my-shop.com'
	static final String SYSTEM_NAME_WITH_DOTS_AND_WHITESPACES_REPLACED = 'live_m_my-shop_com'
	static final DELIMITTER = '_-_'
	static final String PAGE_NAME = 'HP'
	static final String EVENT_NAME = 'HP_event'
	static final String LOCATION_LOCATION = 'netlab1'
	static final String BROWSER_NAME = 'FF'
	static final String MEASURAND_DOCREADYTIME_NAME = 'docReadyTime'

    void setUp() {
		serviceUnderTest = service
		serviceUnderTest.configService = new ConfigService()
		serviceUnderTest.inMemoryConfigService = new InMemoryConfigService()
		ServiceMocker.mockBatchActivityService(serviceUnderTest)
		createTestDataCommonToAllTests()
    }
	
	void createTestDataCommonToAllTests(){
		new CsiAggregationInterval(intervalInMinutes: CsiAggregationInterval.HOURLY).save(validate: false)
		new CsiAggregationInterval(intervalInMinutes: CsiAggregationInterval.DAILY).save(validate: false)
		new CsiAggregationInterval(intervalInMinutes: CsiAggregationInterval.WEEKLY).save(validate: false)
		new AggregatorType(name: AggregatorType.MEASURED_EVENT).save(validate: false)
		new AggregatorType(name: AggregatorType.PAGE).save(validate: false)
		new AggregatorType(name: AggregatorType.SHOP).save(validate: false)
		serviceUnderTest.inMemoryConfigService.activateMeasurementsGenerally()
		new OsmConfiguration().save(failOnError: true)
	}

    void tearDown() {
        // Tear down logic here
    }<commit_msg>Fixed wrong mock method in MetricReportingServiceTests<commit_after>/* 
* OpenSpeedMonitor (OSM)
* Copyright 2014 iteratec GmbH
* 
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
* 	http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*/

package de.iteratec.osm.report.external

import de.iteratec.osm.InMemoryConfigService
import de.iteratec.osm.batch.BatchActivity
import de.iteratec.osm.batch.BatchActivityService
import de.iteratec.osm.util.ServiceMocker
import groovy.mock.interceptor.MockFor

import static org.junit.Assert.assertEquals

import grails.test.mixin.*
import grails.test.mixin.support.*

import org.joda.time.DateTime
import de.iteratec.osm.report.chart.CsiAggregationUtilService
import de.iteratec.osm.measurement.schedule.JobGroup
import de.iteratec.osm.measurement.schedule.dao.JobGroupDaoService

import de.iteratec.osm.csi.Page
import de.iteratec.osm.ConfigService
import de.iteratec.osm.OsmConfiguration
import de.iteratec.osm.report.chart.AggregatorType
import de.iteratec.osm.report.chart.MeasurandGroup
import de.iteratec.osm.report.chart.CsiAggregation
import de.iteratec.osm.report.chart.CsiAggregationInterval
import de.iteratec.osm.report.external.provider.GraphiteSocketProvider
import de.iteratec.osm.csi.EventCsiAggregationService
import de.iteratec.osm.csi.PageCsiAggregationService
import de.iteratec.osm.csi.ShopCsiAggregationService
import de.iteratec.osm.result.CachedView
import de.iteratec.osm.result.EventResult
import de.iteratec.osm.result.MeasuredEvent
import de.iteratec.osm.result.CsiAggregationTagService
import de.iteratec.osm.result.MvQueryParams
import de.iteratec.osm.result.ResultCsiAggregationService
import de.iteratec.osm.measurement.environment.Browser
import de.iteratec.osm.measurement.environment.Location
import de.iteratec.osm.util.I18nService

/**
 * See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
 */
@TestFor(MetricReportingService)
@TestMixin(GrailsUnitTestMixin)
@Mock([EventResult, AggregatorType,JobGroup, BatchActivity, GraphiteServer, GraphitePath, CsiAggregationInterval, Page, MeasuredEvent, Browser, Location, OsmConfiguration])
class MetricReportingServiceTests {
	MetricReportingService serviceUnderTest
	static final double DELTA = 1e-15
	static final DateTime REPORTING_TIMESTAMP = new DateTime(2014,1,22,13,42,0)
	static final DateTime REPORTING_TIMESTAMP_START_OF_DAY = new DateTime(2014,1,22,0,0,0)
	static final DateTime REPORTING_TIMESTAMP_START_OF_WEEK = new DateTime(2014,1,20,0,0,0)
	static final String GRAPHITE_PREFIX = 'my.test.graphite.prefix'
	static final String PAGE_HP_NAME = 'HP'
	static final String SYSTEM_NAME = 'live'
	static final String SYSTEM_NAME_WITH_WHITESPACES = 'live mdot'
	static final String SYSTEM_NAME_WITH_WHITESPACES_REPLACED = 'live_mdot'
	static final String SYSTEM_NAME_WITH_DOTS = 'm.my-shop.com'
	static final String SYSTEM_NAME_WITH_DOTS_REPLACED = 'm_my-shop_com'
	static final String SYSTEM_NAME_WITH_DOTS_AND_WHITESPACES = 'live m.my-shop.com'
	static final String SYSTEM_NAME_WITH_DOTS_AND_WHITESPACES_REPLACED = 'live_m_my-shop_com'
	static final DELIMITTER = '_-_'
	static final String PAGE_NAME = 'HP'
	static final String EVENT_NAME = 'HP_event'
	static final String LOCATION_LOCATION = 'netlab1'
	static final String BROWSER_NAME = 'FF'
	static final String MEASURAND_DOCREADYTIME_NAME = 'docReadyTime'

    void setUp() {
		serviceUnderTest = service
		serviceUnderTest.configService = new ConfigService()
		serviceUnderTest.inMemoryConfigService = new InMemoryConfigService()
		ServiceMocker.create().mockBatchActivityService(serviceUnderTest)
		createTestDataCommonToAllTests()
    }
	
	void createTestDataCommonToAllTests(){
		new CsiAggregationInterval(intervalInMinutes: CsiAggregationInterval.HOURLY).save(validate: false)
		new CsiAggregationInterval(intervalInMinutes: CsiAggregationInterval.DAILY).save(validate: false)
		new CsiAggregationInterval(intervalInMinutes: CsiAggregationInterval.WEEKLY).save(validate: false)
		new AggregatorType(name: AggregatorType.MEASURED_EVENT).save(validate: false)
		new AggregatorType(name: AggregatorType.PAGE).save(validate: false)
		new AggregatorType(name: AggregatorType.SHOP).save(validate: false)
		serviceUnderTest.inMemoryConfigService.activateMeasurementsGenerally()
		new OsmConfiguration().save(failOnError: true)
	}

    void tearDown() {
        // Tear down logic here
    }
{'fraction_non_alphanumeric': 0.08122930463576158, 'fraction_numerical': 0.009519867549668874, 'mean_word_length': 6.327520849128128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6024267', 'n_tokens_mistral': 3261, 'n_tokens_neox': 3083, 'n_words': 653}