-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
81 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
72 changes: 0 additions & 72 deletions
72
.../src/test/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnectorManualTest.java
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
...loader/src/test/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnectorTest.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,88 @@ | ||
/* | ||
* Copyright 2023 Johns Hopkins University | ||
* | ||
* 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 org.eclipse.pass.support.grant.data.jhu; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
import org.eclipse.pass.support.grant.GrantLoaderCLIRunner; | ||
import org.eclipse.pass.support.grant.data.GrantIngestRecord; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
@SpringBootTest | ||
@TestPropertySource("classpath:test-application.properties") | ||
public class JhuGrantDbConnectorTest { | ||
|
||
@MockBean protected GrantLoaderCLIRunner grantLoaderCLIRunner; | ||
@Autowired private JhuGrantDbConnector connector; | ||
|
||
@Test | ||
public void testGrantQuery() throws SQLException { | ||
List<GrantIngestRecord> results = | ||
connector.retrieveUpdates("2011-01-01 00:00:00", "2011-01-01", "grant", null); | ||
List<String> actualAwardNums = results.stream().map(GrantIngestRecord::getAwardNumber).distinct().toList(); | ||
assertEquals(2, actualAwardNums.size()); | ||
assertTrue(actualAwardNums.contains("B10000000")); | ||
assertTrue(actualAwardNums.contains("B10000003")); | ||
} | ||
|
||
@Test | ||
public void testGrantQueryStartDate() throws SQLException { | ||
List<GrantIngestRecord> results = | ||
connector.retrieveUpdates("2023-03-01 00:00:00", "2011-01-01", "grant", null); | ||
List<String> actualAwardNums = results.stream().map(GrantIngestRecord::getAwardNumber).distinct().toList(); | ||
assertEquals(1, actualAwardNums.size()); | ||
assertTrue(actualAwardNums.contains("B10000000")); | ||
} | ||
|
||
@Test | ||
public void testGrantQueryAwardEndDate() throws SQLException { | ||
List<GrantIngestRecord> results = | ||
connector.retrieveUpdates("2011-01-01 00:00:00", "2024-01-01", "grant", null); | ||
List<String> actualAwardNums = results.stream().map(GrantIngestRecord::getAwardNumber).distinct().toList(); | ||
assertEquals(1, actualAwardNums.size()); | ||
assertTrue(actualAwardNums.contains("B10000000")); | ||
} | ||
|
||
@Test | ||
public void testUserQuery() throws SQLException { | ||
List<GrantIngestRecord> results = | ||
connector.retrieveUpdates("2023-03-01 00:00:00", null, "user", null); | ||
assertEquals(1, results.size()); | ||
assertEquals("[email protected]", results.get(0).getPiEmail()); | ||
} | ||
|
||
@Test | ||
public void testFunderQuery() throws SQLException { | ||
List<GrantIngestRecord> results = | ||
connector.retrieveUpdates(null, null, "funder", null); | ||
assertEquals(2, results.size()); | ||
List<String> actualNames = results.stream().map(GrantIngestRecord::getPrimaryFunderName).toList(); | ||
assertTrue(actualNames.contains("Sponsor 1")); | ||
assertTrue(actualNames.contains("Sponsor 2")); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
DELETE FROM JHU_PASS_AWD_VIEW; | ||
DELETE FROM JHU_FIBI_IP_INV_VIEW; | ||
DELETE FROM JHU_PERSON_VIEW; | ||
DELETE FROM JHU_SPONSOR_VIEW; | ||
|
||
INSERT INTO JHU_PASS_AWD_VIEW (INST_PROPOSAL, AWARD_ID, AWARD_STATUS, SAP_GRANT_NUMBER, TITLE, AWARD_DATE, AWARD_START_DATE, | ||
AWARD_END_DATE, SPONSOR_CODE, SPONSOR_NAME, PRIME_SPONSOR_CODE, PRIME_SPONSOR_NAME, | ||
|
@@ -10,10 +14,10 @@ VALUES ('1', '31000000', 'PI'); | |
INSERT INTO JHU_FIBI_IP_INV_VIEW (INST_PROPOSAL, EMPLOYEE_ID, ROLE) | ||
VALUES ('1', '31000001', 'Co-I'); | ||
|
||
INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID) | ||
VALUES ('31000000', 'Amanda', 'Bea', 'Reckondwith', '[email protected]', 'arecko1'); | ||
INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID) | ||
VALUES ('31000001', 'Skip', 'Avery', 'Class', '[email protected]', 'sclass1'); | ||
INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID, UPDATE_TIMESTAMP) | ||
VALUES ('31000000', 'Amanda', 'Bea', 'Reckondwith', '[email protected]', 'arecko1', '2022-03-11 00:00:00.0'); | ||
INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID, UPDATE_TIMESTAMP) | ||
VALUES ('31000001', 'Skip', 'Avery', 'Class', '[email protected]', 'sclass1', '2023-03-11 00:00:00.0'); | ||
|
||
INSERT INTO JHU_PASS_AWD_VIEW (INST_PROPOSAL, AWARD_ID, AWARD_STATUS, SAP_GRANT_NUMBER, TITLE, AWARD_DATE, AWARD_START_DATE, | ||
AWARD_END_DATE, SPONSOR_CODE, SPONSOR_NAME, PRIME_SPONSOR_CODE, PRIME_SPONSOR_NAME, | ||
|
@@ -24,4 +28,8 @@ VALUES('2', 'B10000003', 'Active', '10000002', 'Stupendous Research ProjectIV', | |
INSERT INTO JHU_FIBI_IP_INV_VIEW (INST_PROPOSAL, EMPLOYEE_ID, ROLE) | ||
VALUES ('2', '31000001', 'PI'); | ||
|
||
INSERT INTO JHU_SPONSOR_VIEW (SPONSOR_CODE, SPONSOR_NAME) | ||
VALUES ('20000000', 'Sponsor 1'); | ||
INSERT INTO JHU_SPONSOR_VIEW (SPONSOR_CODE, SPONSOR_NAME) | ||
VALUES ('20000001', 'Sponsor 2'); | ||
|
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