|
|
@@ -1,53 +1,59 @@
|
|
1
|
|
-import static org.assertj.core.api.Assertions.assertThat;
|
|
2
|
|
-import static org.assertj.core.api.Assertions.entry;
|
|
3
|
|
-
|
|
4
|
|
-import org.junit.Test;
|
|
5
|
1
|
import org.junit.Ignore;
|
|
|
2
|
+import org.junit.Test;
|
|
|
3
|
+
|
|
|
4
|
+import java.util.Map;
|
|
|
5
|
+
|
|
|
6
|
+import static org.hamcrest.Matchers.*;
|
|
|
7
|
+import static org.junit.Assert.*;
|
|
6
|
8
|
|
|
7
|
9
|
public class NucleotideTest {
|
|
8
|
10
|
|
|
9
|
11
|
@Test
|
|
10
|
12
|
public void testEmptyDnaStringHasNoAdenosine() {
|
|
11
|
13
|
DNA dna = new DNA("");
|
|
12
|
|
- assertThat(dna.count('A')).isEqualTo(0);
|
|
|
14
|
+ assertThat(dna.count('A'), is(0));
|
|
13
|
15
|
}
|
|
14
|
16
|
|
|
15
|
17
|
@Ignore
|
|
16
|
18
|
@Test
|
|
17
|
19
|
public void testEmptyDnaStringHasNoNucleotides() {
|
|
18
|
20
|
DNA dna = new DNA("");
|
|
19
|
|
- assertThat(dna.nucleotideCounts()).hasSize(4).contains(
|
|
20
|
|
- entry('A', 0),
|
|
21
|
|
- entry('C', 0),
|
|
22
|
|
- entry('G', 0),
|
|
23
|
|
- entry('T', 0)
|
|
24
|
|
- );
|
|
|
21
|
+ Map<Character, Integer> counts = dna.nucleotideCounts();
|
|
|
22
|
+ assertThat(counts.size(), is(4));
|
|
|
23
|
+ assertThat(counts, allOf(
|
|
|
24
|
+ hasEntry('A', 0),
|
|
|
25
|
+ hasEntry('C', 0),
|
|
|
26
|
+ hasEntry('G', 0),
|
|
|
27
|
+ hasEntry('T', 0)
|
|
|
28
|
+ ));
|
|
25
|
29
|
}
|
|
26
|
30
|
|
|
27
|
31
|
@Ignore
|
|
28
|
32
|
@Test
|
|
29
|
33
|
public void testRepetitiveCytidineGetsCounted() {
|
|
30
|
34
|
DNA dna = new DNA("CCCCC");
|
|
31
|
|
- assertThat(dna.count('C')).isEqualTo(5);
|
|
|
35
|
+ assertThat(dna.count('C'), is(5));
|
|
32
|
36
|
}
|
|
33
|
37
|
|
|
34
|
38
|
@Ignore
|
|
35
|
39
|
@Test
|
|
36
|
40
|
public void testRepetitiveSequenceWithOnlyGuanosine() {
|
|
37
|
41
|
DNA dna = new DNA("GGGGGGGG");
|
|
38
|
|
- assertThat(dna.nucleotideCounts()).hasSize(4).contains(
|
|
39
|
|
- entry('A', 0),
|
|
40
|
|
- entry('C', 0),
|
|
41
|
|
- entry('G', 8),
|
|
42
|
|
- entry('T', 0)
|
|
43
|
|
- );
|
|
|
42
|
+ Map<Character, Integer> counts = dna.nucleotideCounts();
|
|
|
43
|
+ assertThat(counts.size(), is(4));
|
|
|
44
|
+ assertThat(counts, allOf(
|
|
|
45
|
+ hasEntry('A', 0),
|
|
|
46
|
+ hasEntry('C', 0),
|
|
|
47
|
+ hasEntry('G', 8),
|
|
|
48
|
+ hasEntry('T', 0)
|
|
|
49
|
+ ));
|
|
44
|
50
|
}
|
|
45
|
51
|
|
|
46
|
52
|
@Ignore
|
|
47
|
53
|
@Test
|
|
48
|
54
|
public void testCountsOnlyThymidine() {
|
|
49
|
55
|
DNA dna = new DNA("GGGGGTAACCCGG");
|
|
50
|
|
- assertThat(dna.count('T')).isEqualTo(1);
|
|
|
56
|
+ assertThat(dna.count('T'), is(1));
|
|
51
|
57
|
}
|
|
52
|
58
|
|
|
53
|
59
|
@Ignore
|
|
|
@@ -55,7 +61,7 @@ public class NucleotideTest {
|
|
55
|
61
|
public void testCountsANucleotideOnlyOnce() {
|
|
56
|
62
|
DNA dna = new DNA("CGATTGGG");
|
|
57
|
63
|
dna.count('T');
|
|
58
|
|
- assertThat(dna.count('T')).isEqualTo(2);
|
|
|
64
|
+ assertThat(dna.count('T'), is(2));
|
|
59
|
65
|
}
|
|
60
|
66
|
|
|
61
|
67
|
@Ignore
|
|
|
@@ -63,12 +69,14 @@ public class NucleotideTest {
|
|
63
|
69
|
public void testDnaCountsDoNotChangeAfterCountingAdenosine() {
|
|
64
|
70
|
DNA dna = new DNA("GATTACA");
|
|
65
|
71
|
dna.count('A');
|
|
66
|
|
- assertThat(dna.nucleotideCounts()).hasSize(4).contains(
|
|
67
|
|
- entry('A', 3),
|
|
68
|
|
- entry('C', 1),
|
|
69
|
|
- entry('G', 1),
|
|
70
|
|
- entry('T', 2)
|
|
71
|
|
- );
|
|
|
72
|
+ Map<Character, Integer> counts = dna.nucleotideCounts();
|
|
|
73
|
+ assertThat(counts.size(), is(4));
|
|
|
74
|
+ assertThat(counts, allOf(
|
|
|
75
|
+ hasEntry('A', 3),
|
|
|
76
|
+ hasEntry('C', 1),
|
|
|
77
|
+ hasEntry('G', 1),
|
|
|
78
|
+ hasEntry('T', 2)
|
|
|
79
|
+ ));
|
|
72
|
80
|
}
|
|
73
|
81
|
|
|
74
|
82
|
@Ignore
|
|
|
@@ -83,11 +91,13 @@ public class NucleotideTest {
|
|
83
|
91
|
public void testCountsAllNucleotides() {
|
|
84
|
92
|
String s = "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC";
|
|
85
|
93
|
DNA dna = new DNA(s);
|
|
86
|
|
- assertThat(dna.nucleotideCounts()).hasSize(4).contains(
|
|
87
|
|
- entry('A', 20),
|
|
88
|
|
- entry('C', 12),
|
|
89
|
|
- entry('G', 17),
|
|
90
|
|
- entry('T', 21)
|
|
91
|
|
- );
|
|
|
94
|
+ Map<Character, Integer> counts = dna.nucleotideCounts();
|
|
|
95
|
+ assertThat(counts.size(), is(4));
|
|
|
96
|
+ assertThat(counts, allOf(
|
|
|
97
|
+ hasEntry('A', 20),
|
|
|
98
|
+ hasEntry('C', 12),
|
|
|
99
|
+ hasEntry('G', 17),
|
|
|
100
|
+ hasEntry('T', 21)
|
|
|
101
|
+ ));
|
|
92
|
102
|
}
|
|
93
|
103
|
}
|