@@ -0,0 +1,3316 @@
+/*%0A * European Variation Archive (EVA) - Open-access database of all types of genetic%0A * variation data from all species%0A *%0A * Copyright 2017 EMBL - European Bioinformatics Institute%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage uk.ac.ebi.eva.server.ws.ga4gh;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.mock.mockito.MockBean;%0Aimport org.springframework.boot.test.web.client.TestRestTemplate;%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport uk.ac.ebi.eva.commons.models.metadata.VariantEntity;%0Aimport uk.ac.ebi.eva.lib.repository.VariantEntityRepository;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Matchers.anyInt;%0Aimport static org.mockito.Matchers.eq;%0A%0A@RunWith(SpringRunner.class)%0A@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)%0Apublic class GA4GHBeaconWSServerTest %7B%0A%0A    private static final VariantEntity VARIANT = new VariantEntity(%221%22, 1000, 1005, %22reference%22, %22alternate%22);%0A%0A    @Autowired%0A    private TestRestTemplate restTemplate;%0A%0A    @MockBean%0A    private VariantEntityRepository variantEntityRepository;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        List%3CVariantEntity%3E variantEntities = Collections.singletonList(VARIANT);%0A%0A        given(variantEntityRepository.findByChromosomeAndStartAndAltAndStudyIn(eq(%221%22), anyInt(), any(), any()))%0A                .willReturn(variantEntities);%0A    %7D%0A%0A    @Test%0A    public void testAltAlleleExistsBeacon() throws Exception %7B%0A        assertTrue(testBeaconHelper(%221%22, 1000, %22alternate%22, new ArrayList%3C%3E()));%0A    %7D%0A%0A    private Boolean testBeaconHelper(String chromosome, int start, String allele, List%3CString%3E datasetIds) %7B%0A        String url = String.format(%22/v1/ga4gh/beacon?referenceName=%25s&start=%25d&allele=%25s&datasetIds=%25s%22,%0A                                   chromosome,%0A                                   start,%0A                                   allele,%0A                                   String.join(%22,%22, datasetIds));%0A        ResponseEntity%3CGA4GHBeaconResponse%3E response = restTemplate.getForEntity(%0A                url, GA4GHBeaconResponse.class);%0A%0A        assertEquals(HttpStatus.OK, response.getStatusCode());%0A%0A        GA4GHBeaconResponse ga4GHBeaconResponse = response.getBody();%0A        return ga4GHBeaconResponse.isExists();%0A    %7D%0A%7D

Test for GA4GH beacon for existing variant