Skip to content

Commit 408e875

Browse files
committed
refactor CMetricDataGathererTest.cc
1 parent de4785f commit 408e875

File tree

2 files changed

+5
-61
lines changed

2 files changed

+5
-61
lines changed

lib/model/unittest/CEventRateDataGathererTest.cc

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -63,60 +63,7 @@ namespace {
6363
const CSearchKey key;
6464
const std::string EMPTY_STRING;
6565

66-
class CDataGathererBuilder {
67-
public:
68-
CDataGathererBuilder(const TFeatureVec& features, const SModelParams& params, const CSearchKey& searchKey,
69-
const core_t::TTime startTime
70-
): m_Features(features), m_Params(params), m_StartTime(startTime), m_SearchKey(searchKey) {}
71-
72-
CDataGatherer build() const {
73-
return {m_GathererType, m_SummaryMode, m_Params, m_SummaryCountFieldName,
74-
m_PartitionFieldValue, m_PersonFieldName, m_AttributeFieldName,
75-
m_ValueFieldName, m_InfluenceFieldNames, m_SearchKey, m_Features,
76-
m_StartTime, m_SampleCountOverride};
77-
}
78-
79-
CDataGathererBuilder& personFieldName(const std::string& personFieldName) {
80-
m_PersonFieldName = personFieldName;
81-
return *this;
82-
}
83-
84-
CDataGathererBuilder& valueFieldName(const std::string& valueFieldName) {
85-
m_ValueFieldName = valueFieldName;
86-
return *this;
87-
}
88-
89-
CDataGathererBuilder& influenceFieldNames(const TStrVec& influenceFieldName) {
90-
m_InfluenceFieldNames = influenceFieldName;
91-
return *this;
92-
}
9366

94-
CDataGathererBuilder& attributeFieldName(const std::string& attributeFieldName) {
95-
m_AttributeFieldName = attributeFieldName;
96-
return *this;
97-
}
98-
99-
CDataGathererBuilder& gathererType(model_t::EAnalysisCategory gathererType) {
100-
m_GathererType = gathererType;
101-
return *this;
102-
}
103-
104-
private:
105-
const TFeatureVec& m_Features;
106-
const SModelParams& m_Params;
107-
core_t::TTime m_StartTime;
108-
const CSearchKey& m_SearchKey;
109-
model_t::EAnalysisCategory m_GathererType{model_t::E_EventRate};
110-
model_t::ESummaryMode m_SummaryMode{model_t::E_None};
111-
std::string m_SummaryCountFieldName{EMPTY_STRING};
112-
std::string m_PartitionFieldValue{EMPTY_STRING};
113-
std::string m_PersonFieldName{EMPTY_STRING};
114-
std::string m_AttributeFieldName{EMPTY_STRING};
115-
std::string m_ValueFieldName{EMPTY_STRING};
116-
TStrVec m_InfluenceFieldNames;
117-
int m_SampleCountOverride{0};
118-
119-
};
12067

12168
std::size_t addPerson(CDataGatherer& gatherer,
12269
CResourceMonitor& resourceMonitor,
@@ -221,7 +168,7 @@ void testInfluencerPerFeature(const model_t::EFeature feature,
221168
features.push_back(feature);
222169
TStrVec influencerFieldNames;
223170
influencerFieldNames.emplace_back("IF1");
224-
CDataGatherer gatherer = CDataGathererBuilder(features, params, key, startTime)
171+
CDataGatherer gatherer = CDataGathererBuilder(model_t::E_EventRate, features, params, key, startTime)
225172
.influenceFieldNames(influencerFieldNames)
226173
.valueFieldName(valueField)
227174
.build();

lib/model/unittest/CMetricDataGathererTest.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,10 +1128,7 @@ BOOST_FIXTURE_TEST_CASE(testResetBucketGivenMultipleSeries, CTestFixture) {
11281128
features.push_back(model_t::E_IndividualMinByPerson);
11291129
features.push_back(model_t::E_IndividualMaxByPerson);
11301130
features.push_back(model_t::E_IndividualSumByBucketAndPerson);
1131-
CDataGatherer gatherer =
1132-
CDataGathererBuilder(model_t::E_Metric, features, params, KEY, startTime)
1133-
.sampleCountOverride(2U)
1134-
.build();
1131+
CDataGatherer gatherer = CDataGathererBuilder(model_t::E_Metric,features, params, KEY, startTime).sampleCountOverride(2U).build();
11351132
addPerson("p1", gatherer, m_ResourceMonitor);
11361133
addPerson("p2", gatherer, m_ResourceMonitor);
11371134
addPerson("p3", gatherer, m_ResourceMonitor);
@@ -1604,9 +1601,9 @@ BOOST_FIXTURE_TEST_CASE(testMultivariate, CTestFixture) {
16041601
{
16051602
TFeatureVec features;
16061603
features.push_back(model_t::E_IndividualMeanLatLongByPerson);
1607-
CDataGatherer gatherer = CDataGathererBuilder(model_t::E_Metric, features,
1608-
params, KEY, startTime)
1609-
.build();
1604+
CDataGatherer gatherer(model_t::E_Metric, model_t::E_None, params,
1605+
EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING,
1606+
EMPTY_STRING, {}, KEY, features, startTime, 0);
16101607
BOOST_REQUIRE_EQUAL(0, addPerson("p", gatherer, m_ResourceMonitor));
16111608

16121609
TTimeDoubleDoubleTupleVecVec buckets;

0 commit comments

Comments
 (0)