Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
variety
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
variety
Commits
5a9fc8b4
Commit
5a9fc8b4
authored
Jan 31, 2015
by
Tomas Dvorak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests updated to changed query and limit behaviour.
parent
4c6c5045
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
LimitResultsAnalysisTest.java
...ava/com/github/variety/test/LimitResultsAnalysisTest.java
+7
-6
QueryLimitedAnalysisTest.java
...ava/com/github/variety/test/QueryLimitedAnalysisTest.java
+8
-6
SortedAnalysisTest.java
...test/java/com/github/variety/test/SortedAnalysisTest.java
+6
-5
No files found.
test/src/test/java/com/github/variety/test/LimitResultsAnalysisTest.java
View file @
5a9fc8b4
...
...
@@ -2,13 +2,13 @@ package com.github.variety.test;
import
com.github.variety.Variety
;
import
com.github.variety.validator.ResultsValidator
;
import
com.mongodb.DBObject
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
/**
* Tests limit functionality of variety. It should analyse only first _n_ objects and then compute occurrences from
* all objects in collection.
* Tests limit functionality of variety. It should analyse only first _n_ objects.
*/
public
class
LimitResultsAnalysisTest
{
...
...
@@ -29,9 +29,10 @@ public class LimitResultsAnalysisTest {
@Test
public
void
verifyLimitedResults
()
throws
Exception
{
final
ResultsValidator
analysis
=
variety
.
withLimit
(
1
).
runDatabaseAnalysis
();
analysis
.
validate
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
validate
(
"name"
,
5
,
100
,
"String"
);
analysis
.
validate
(
"someBinData"
,
1
,
20
,
"BinData-old"
);
// limit=1 without other params selects the last inserted document (see SampleData class)
// it should equals {name: "Jim", someBinData: new BinData(2,"1234")}
analysis
.
validate
(
"_id"
,
1
,
100
,
"ObjectId"
);
analysis
.
validate
(
"name"
,
1
,
100
,
"String"
);
analysis
.
validate
(
"someBinData"
,
1
,
100
,
"BinData-old"
);
}
}
test/src/test/java/com/github/variety/test/QueryLimitedAnalysisTest.java
View file @
5a9fc8b4
...
...
@@ -24,13 +24,15 @@ public class QueryLimitedAnalysisTest {
@Test
public
void
testQueryLimitedAnalysis
()
throws
Exception
{
final
ResultsValidator
analysis
=
variety
.
withQuery
(
"{someBinData:{$exists: true}}"
).
runDatabaseAnalysis
();
Assert
.
assertEquals
(
3
,
analysis
.
getResultsCount
());
final
ResultsValidator
analysis
=
variety
.
withQuery
(
"{birthday:{$exists: true}}"
).
runDatabaseAnalysis
();
Assert
.
assertEquals
(
5
,
analysis
.
getResultsCount
());
analysis
.
validate
(
"_id"
,
2
,
100
,
"ObjectId"
);
analysis
.
validate
(
"birthday"
,
2
,
100
,
"String"
);
analysis
.
validate
(
"name"
,
2
,
100
,
"String"
);
analysis
.
validate
(
"bio"
,
1
,
50
,
"String"
);
analysis
.
validate
(
"pets"
,
1
,
50
,
"String"
);
// we analyzed only the keys of objects defined by query. But total counts and percents are computed from the complete collection
analysis
.
validate
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
validate
(
"name"
,
5
,
100
,
"String"
);
analysis
.
validate
(
"someBinData"
,
1
,
20
,
"BinData-old"
);
}
}
test/src/test/java/com/github/variety/test/SortedAnalysisTest.java
View file @
5a9fc8b4
...
...
@@ -45,15 +45,16 @@ public class SortedAnalysisTest {
// when sorting default SampleData by name desc, first entry becomes Tom. He is only with key 'someWeirdLegacyKey'
// Together with applying limit 1, Tom is the only result in analysis. That gives us chance to assume keys and verify
// that ordering is correct.
// {name: "Tom", bio: "A nice guy.", pets: ["monkey", "fish"], someWeirdLegacyKey: "I like Ike!"}
final
ResultsValidator
analysis
=
variety
.
withSort
(
"{name:-1}"
).
withLimit
(
1
).
runDatabaseAnalysis
();
Assert
.
assertEquals
(
5
,
analysis
.
getResultsCount
());
analysis
.
validate
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
validate
(
"name"
,
5
,
100
,
"String"
);
analysis
.
validate
(
"bio"
,
3
,
6
0
,
"String"
);
analysis
.
validate
(
"pets"
,
2
,
4
0
,
"Array"
);
analysis
.
validate
(
"someWeirdLegacyKey"
,
1
,
2
0
,
"String"
);
analysis
.
validate
(
"_id"
,
1
,
100
,
"ObjectId"
);
analysis
.
validate
(
"name"
,
1
,
100
,
"String"
);
analysis
.
validate
(
"bio"
,
1
,
10
0
,
"String"
);
analysis
.
validate
(
"pets"
,
1
,
10
0
,
"Array"
);
analysis
.
validate
(
"someWeirdLegacyKey"
,
1
,
10
0
,
"String"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment