diff --git a/src/test/java/org/mskcc/cbio/oncokb/service/CompanyServiceIT.java b/src/test/java/org/mskcc/cbio/oncokb/service/CompanyServiceIT.java index 29f895010..b0fcc3c55 100644 --- a/src/test/java/org/mskcc/cbio/oncokb/service/CompanyServiceIT.java +++ b/src/test/java/org/mskcc/cbio/oncokb/service/CompanyServiceIT.java @@ -465,4 +465,32 @@ public void assertThatRegularUserStatusRemainTheSameAfterLinkedWithTrialCompany( assertThat(latestUserDTO.isActivated()).isTrue(); } + @Test + @Transactional + public void assertThatCreatingNewServiceAccountTokenAlsoCreatesServiceAccount() { + CompanyDTO company = companyService.createCompany(companyDTO); + assertThat(company.getServiceUsers().size() == 0); + + // Should create service user and new token + Long id = company.getId(); + Token token = companyService.createServiceAccountToken(company.getId(), "New token").get(); + company = companyService.findOne(company.getId()).get(); + assertThat(company.getServiceUsers().size() == 1); + assertThat(tokenService.findByToken(token.getToken()).get().getName() == "New token"); + } + + @Test + @Transactional + public void assertThatOnlyOneServiceUserCanBeCreatedPerCompany() { + CompanyDTO company = companyService.createCompany(companyDTO); + assertThat(company.getServiceUsers().size() == 0); + + companyService.createServiceAccount(company.getId()); + company = companyService.findOne(company.getId()).get(); + assertThat(company.getServiceUsers().size() == 1); + + companyService.createServiceAccount(company.getId()); + company = companyService.findOne(company.getId()).get(); + assertThat(company.getServiceUsers().size() == 1); + } }