-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from Ravina-Deogadkar/tests
Add Additional testcases
- Loading branch information
Showing
6 changed files
with
231 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package DNAnalyzer.core; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class PropertiesTest { | ||
|
||
Path projectPath = Path.of(""); | ||
Path dnaLongTestInput = projectPath.resolve("assets/dna/random/dnalong.fa"); | ||
|
||
String dnaString=""; | ||
@BeforeEach | ||
void setUp() { | ||
try { | ||
List<String> inputLines = Files.readAllLines(dnaLongTestInput); | ||
dnaString = inputLines.get(0); | ||
} catch (IOException ex) { | ||
Logger.getLogger(PropertiesTest.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
||
@Test | ||
void shouldGetGCContent() { | ||
double expected = 0.5000109; | ||
float actual = Properties.getGCContent(dnaString); | ||
assertEquals(expected, actual,0.01); | ||
|
||
} | ||
|
||
@Test | ||
void shouldGetGCContentAsZero() { | ||
// List<String> inputLines = Files.readAllLines(dnaLongTestInput); | ||
String testEmptyString = ""; | ||
double expected = 0; | ||
float actual = Properties.getGCContent(testEmptyString); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
void sholudCalculateLengthOfCG() { | ||
int expected = 50001033; | ||
int actual = Properties.calculateLengthOfCG(dnaString); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
void sholudCalculateLengthOfCGAsZero() { | ||
String testEmptyString = ""; | ||
int expected = 0; | ||
int actual = Properties.calculateLengthOfCG(testEmptyString); | ||
assertEquals(expected, actual); | ||
} | ||
@Test | ||
void shouldLetterIsCorGReturnTrue() { | ||
boolean actual = Properties.letterIsCorG('c'); | ||
assertTrue(actual); | ||
} | ||
|
||
@Test | ||
void shouldLetterIsCorGReturnFalse() { | ||
boolean actual = Properties.letterIsCorG('b'); | ||
assertFalse(actual); | ||
} | ||
|
||
@Test | ||
void shouldIsRandomDNAReturnTrue() { | ||
boolean actual = Properties.isRandomDNA(dnaString); | ||
assertTrue(actual); | ||
} | ||
|
||
// @Test | ||
// void shouldIsRandomDNAReturnFalse() { | ||
// String testEmptyString = ""; | ||
// boolean actual = Properties.isRandomDNA(testEmptyString); | ||
// assertFalse(actual); | ||
// } | ||
|
||
@Test | ||
void shouldIsDifferenceLessOrEqualTo2ReturnTrue() { | ||
boolean actual = Properties.isDifferenceLessOrEqualTo2(10,9); | ||
assertTrue(actual); | ||
} | ||
|
||
@Test | ||
void shouldIsDifferenceLessOrEqualTo2ReturnFalse() { | ||
boolean actual = Properties.isDifferenceLessOrEqualTo2(10,1); | ||
assertFalse(actual); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package DNAnalyzer.utils.core; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class DNAToolsTest { | ||
|
||
DNATools dnaTools; | ||
String dnaString; | ||
Path projectPath = Path.of(""); | ||
Path dnaLongTestInput = projectPath.resolve("assets/dna/random/dnalong.fa"); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
try { | ||
List<String> inputLines = Files.readAllLines(dnaLongTestInput); | ||
dnaString = inputLines.get(0); | ||
|
||
} catch (IOException ex) { | ||
Logger.getLogger(DNAToolsTest.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
||
@Test | ||
void shouldIsValidThrowException() { | ||
dnaTools = new DNATools(""); | ||
var expected = "Invalid characters present in DNA sequence."; | ||
Exception exception = assertThrows(IllegalArgumentException.class, ()->dnaTools.isValid() ); | ||
assertEquals(expected, exception.getMessage()); | ||
} | ||
|
||
@Test | ||
void shouldIsValidNotThrowException() { | ||
dnaTools = new DNATools("atgc"); | ||
assertDoesNotThrow(()->dnaTools.isValid() ); | ||
} | ||
|
||
@Test | ||
void shouldReplaceDNAString() { | ||
var expected = "AAAacggctcaaaacca"; | ||
dnaTools = new DNATools("gagacggctcaaaacca"); | ||
var newDnaTools = dnaTools.replace("gag", "AAA"); | ||
var actual = newDnaTools.getDna(); | ||
assertEquals(expected,actual); | ||
} | ||
|
||
@Test | ||
void shouldReverseDNAString() { | ||
var expected = "cagag"; | ||
dnaTools = new DNATools("gagac"); | ||
var newDnaTools = dnaTools.reverse(); | ||
var actual = newDnaTools.getDna(); | ||
assertEquals(expected,actual); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/test/java/DNAnalyzer/utils/core/ReadingFramesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package DNAnalyzer.utils.core; | ||
|
||
import DNAnalyzer.data.codon.CodonFrame; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
|
||
class ReadingFramesTest { | ||
|
||
ReadingFrames readingFrames; | ||
Path projectPath = Path.of(""); | ||
Path dnaLongTestInput = projectPath.resolve("assets/dna/random/dnalong.fa"); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
try { | ||
List<String> inputLines = Files.readAllLines(dnaLongTestInput); | ||
readingFrames= new ReadingFrames(new CodonFrame(inputLines.get(0), (short) 1, 2, 100)); | ||
|
||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/test/java/DNAnalyzer/utils/protein/ProteinAnalysisTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package DNAnalyzer.utils.protein; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
|
||
class ProteinAnalysisTest { | ||
|
||
Path projectPath = Path.of(""); | ||
Path dnaLongTestInput = projectPath.resolve("assets/dna/random/dnalong.fa"); | ||
|
||
String dnaString=""; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
try { | ||
List<String> inputLines = Files.readAllLines(dnaLongTestInput); | ||
dnaString = inputLines.get(0); | ||
} catch (IOException ex) { | ||
Logger.getLogger(ProteinAnalysisTest.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
|
||
} | ||
|
||
} |