Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVA-2217 Improve release api #143

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
add tests
andresfsilva committed Nov 24, 2020
commit 94f22796ba0e3fb5560bf1d8335a017625ff02a4
4 changes: 4 additions & 0 deletions eva-release/pom.xml
Original file line number Diff line number Diff line change
@@ -55,6 +55,10 @@
<artifactId>springfox-swagger2</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencies>

<build>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2020 EMBL - European Bioinformatics Institute
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.ac.ebi.eva.release.controllers;

import org.assertj.core.util.IterableUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import uk.ac.ebi.eva.release.Application;
import uk.ac.ebi.eva.release.models.ReleaseInfo;

import static org.junit.Assert.assertEquals;

@SpringBootTest(classes = Application.class)
@RunWith(SpringRunner.class)
public class ReleaseInfoControllerTest {

@Autowired
private ReleaseInfoController releaseInfoController;

@Test
public void getOneReleaseInfo() {
int releaseVersion = 1;
Iterable<ReleaseInfo> releaseInfo = releaseInfoController.getReleaseInfo(releaseVersion);
assertEquals(releaseVersion, releaseInfo.iterator().next().getReleaseVersion());
}

@Test
public void getAllReleasesInfo() {
Integer releaseVersion = null;
Iterable<ReleaseInfo> releaseInfo = releaseInfoController.getReleaseInfo(releaseVersion);
assertEquals(2, IterableUtil.sizeOf(releaseInfo));
}

@Test
public void getLatestReleaseInfo() {
int latestReleaseVersion = 2;
ReleaseInfo latestReleaseInfo = releaseInfoController.getLatestReleaseInfo();
assertEquals(latestReleaseVersion, latestReleaseInfo.getReleaseVersion());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2020 EMBL - European Bioinformatics Institute
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.ac.ebi.eva.release.controllers;

import org.assertj.core.util.IterableUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import uk.ac.ebi.eva.release.Application;
import uk.ac.ebi.eva.release.dto.ReleaseStatsPerSpeciesDto;

import static org.junit.Assert.assertEquals;

@SpringBootTest(classes = Application.class)
@RunWith(SpringRunner.class)
public class ReleaseStatsControllerTest {

@Autowired
private ReleaseStatsController releaseStatsController;

@Test
public void getAllSpeciesStats() {
int totalNumberOfRecords = 417;
Iterable<ReleaseStatsPerSpeciesDto> allRecords = releaseStatsController.getReleaseStatsPerSpecies(null, false);
assertEquals(totalNumberOfRecords, IterableUtil.sizeOf(allRecords));
}

@Test
public void getStatsByReleaseVersion() {
int speciesInRelease2 = 218;
Iterable<ReleaseStatsPerSpeciesDto> allRecords = releaseStatsController.getReleaseStatsPerSpecies(2, false);
assertEquals(speciesInRelease2, IterableUtil.sizeOf(allRecords));
}

@Test
public void getStatsByReleaseVersionNoUnmapped() {
int speciesInRelease2ExcludingUnmapped = 22;
Iterable<ReleaseStatsPerSpeciesDto> allRecords = releaseStatsController.getReleaseStatsPerSpecies(2, true);
assertEquals(speciesInRelease2ExcludingUnmapped, IterableUtil.sizeOf(allRecords));
}

@Test
public void getStatsForNewVariantsOnlyInSpecificRelease() {
int numberOfSpeciesWithNewVariants = 29;
Iterable<ReleaseStatsPerSpeciesDto> allRecords = releaseStatsController.getSpeciesWithNewRsIds(2);
assertEquals(numberOfSpeciesWithNewVariants, IterableUtil.sizeOf(allRecords));
}
}
10 changes: 10 additions & 0 deletions eva-release/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring.datasource.driver-class-name=org.hsqldb.jdbcDriver
spring.datasource.url=jdbc:hsqldb:mem:db;sql.syntax_pgs=true;DB_CLOSE_DELAY=-1
spring.datasource.username=SA
spring.datasource.password=

spring.jpa.generate-ddl=true
spring.jpa.show-sql=true

# See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#bean-overriding
spring.main.allow-bean-definition-overriding=true
504 changes: 504 additions & 0 deletions eva-release/src/test/resources/data.sql

Large diffs are not rendered by default.