Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public class RnaTranscription {
class RnaTranscription {

public String transcribe(String dnaStrand) {
String transcribe(String dnaStrand) {
StringBuilder sb = new StringBuilder();
for (char c : dnaStrand.toCharArray()) {
switch (c) {
Expand All @@ -21,6 +21,8 @@ public String transcribe(String dnaStrand) {

}
}

return sb.toString();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
public class RnaTranscription {
public String transcribe(String dnaStrand) {
class RnaTranscription {

String transcribe(String dnaStrand) {
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
}
}

}
47 changes: 21 additions & 26 deletions exercises/rna-transcription/src/test/java/RnaTranscriptionTest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.Rule;

public class RnaTranscriptionTest {
import static org.junit.Assert.assertEquals;

/*
version: 2.0.0
*/
/*
* version: 1.0.1
*/
public class RnaTranscriptionTest {

@Rule
public ExpectedException thrown = ExpectedException.none();
public ExpectedException expectedException = ExpectedException.none();

private RnaTranscription rnaTranscription;

Expand All @@ -21,62 +21,57 @@ public void setUp() {
rnaTranscription = new RnaTranscription();
}

@Test
public void testRnaTranscriptionOfEmptyDnaIsEmptyRna() {
Assert.assertEquals("", rnaTranscription.transcribe(""));
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfCytosineIsGuanine() {
Assert.assertEquals("G", rnaTranscription.transcribe("C"));
assertEquals("G", rnaTranscription.transcribe("C"));
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfGuanineIsCytosine() {
Assert.assertEquals("C", rnaTranscription.transcribe("G"));
assertEquals("C", rnaTranscription.transcribe("G"));
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfThymineIsAdenine() {
Assert.assertEquals("A", rnaTranscription.transcribe("T"));
assertEquals("A", rnaTranscription.transcribe("T"));
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfAdenineIsUracil() {
Assert.assertEquals("U", rnaTranscription.transcribe("A"));
assertEquals("U", rnaTranscription.transcribe("A"));
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscription() {
Assert.assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfRnaThrowsAnError() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid input");
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Invalid input");
rnaTranscription.transcribe("U");
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfInvalidInputThrowsAnError() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid input");
rnaTranscription.transcribe("BFV");
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Invalid input");
rnaTranscription.transcribe("XXX");
}

@Ignore("Remove to run test")
@Test
public void testRnaTranscriptionOfPartiallyInvalidInput() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid input");
rnaTranscription.transcribe("GCVV");
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Invalid input");
rnaTranscription.transcribe("ACGTXXXCTTAA");
}

}