Skip to content

Commit

Permalink
AJ-2027: clean up compile warnings and unit test output (#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidangb authored Oct 4, 2024
1 parent da91ced commit 6467c38
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions project/Testing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object Testing {
val commonTestSettings: Seq[Setting[_]] = List(

Test / testOptions ++= Seq(Tests.Filter(s => !isIntegrationTest(s))),
Test / testOptions += Tests.Argument("-oD"), // D = individual test durations
IntegrationTest / testOptions := Seq(Tests.Filter(s => isIntegrationTest(s))),

// ES client attempts to set the number of processors that Netty should use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class NihService(val samDao: SamDAO, val thurloeDao: ThurloeDAO, val googleDao:
ecmDao.putLinkedEraAccount(LinkedEraAccount(userInfo.id, nihLink))(getAdminAccessToken)
.flatMap(_ => {
logger.info("Successfully linked NIH account in ECM for user " + userInfo.id)
Future.successful(Success())
Future.successful(Success(()))
}).recoverWith {
case e =>
logger.warn("Failed to link NIH account in ECM for user" + userInfo.id)
Expand Down Expand Up @@ -249,6 +249,7 @@ class NihService(val samDao: SamDAO, val thurloeDao: ThurloeDAO, val googleDao:
case (Failure(t), Success(_)) => logger.error("Failed to link NIH Account in Thurloe", t)
case (Success(_), Failure(t)) => logger.error("Failed to link NIH Account in ECM", t)
case (Failure(t1), Failure(t2)) => logger.error("Failed to link NIH Account in Thurloe and ECM", t1, t2)
case _ => // unreachable case due to the if-condition above, but this case avoids compile warnings
}
RequestCompleteWithErrorReport(InternalServerError, "Error updating NIH link")
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</encoder>
</appender>

<logger name="PerformanceLogging" level="warn" additivity="false">
<logger name="PerformanceLogging" level="off" additivity="false">
<appender-ref ref="console"/>
</logger>

<logger name="org.broadinstitute.dsde" level="error" additivity="false">
<logger name="org.broadinstitute.dsde" level="off" additivity="false">
<appender-ref ref="console"/>
</logger>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class NihServiceUnitSpec extends AnyFlatSpec with Matchers with BeforeAndAfterEa
})
when(samDao.overwriteGroupMembers(any(), any(), any())(any())).thenReturn(Future.failed(new RuntimeException(errorMessage)))
when(samDao.listGroups(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful(samGroupMemberships.keys.map(groupName => FireCloudManagedGroupMembership(groupName, groupName + "@firecloud.org", "member")).toList))
when(samDao.createGroup(any[WorkbenchGroupName])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful())
when(samDao.createGroup(any[WorkbenchGroupName])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful(()))

val ex = intercept[FireCloudException] {
Await.result(nihService.syncAllowlistAllUsers("TARGET"), Duration.Inf)
Expand Down Expand Up @@ -364,7 +364,7 @@ class NihServiceUnitSpec extends AnyFlatSpec with Matchers with BeforeAndAfterEa
}

private def mockSamUsers(): Unit = {
when(samDao.overwriteGroupMembers(any(), any(), any())(any())).thenReturn(Future.successful())
when(samDao.overwriteGroupMembers(any(), any(), any())(any())).thenReturn(Future.successful(()))
when(samDao.listGroups(any[WithAccessToken])).thenAnswer(args => {
Future {
val userInfo = args.getArgument(0).asInstanceOf[WithAccessToken]
Expand All @@ -376,14 +376,14 @@ class NihServiceUnitSpec extends AnyFlatSpec with Matchers with BeforeAndAfterEa
.getOrElse(List.empty)
}
})
when(samDao.addGroupMember(any(), any(), any())(any())).thenReturn(Future.successful())
when(samDao.removeGroupMember(any(), any(), any())(any())).thenReturn(Future.successful())
when(samDao.addGroupMember(any(), any(), any())(any())).thenReturn(Future.successful(()))
when(samDao.removeGroupMember(any(), any(), any())(any())).thenReturn(Future.successful(()))
when(samDao.isGroupMember(any[WorkbenchGroupName], any[UserInfo])).thenAnswer(args => Future {
val groupName = args.getArgument(0).asInstanceOf[WorkbenchGroupName]
val userInfo = args.getArgument(1).asInstanceOf[UserInfo]
samGroupMemberships.get(groupName.value).exists(_.exists(_.value == userInfo.id))
})
when(samDao.createGroup(any[WorkbenchGroupName])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful())
when(samDao.createGroup(any[WorkbenchGroupName])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful(()))
when(samDao.getUsersForIds(any[Seq[WorkbenchUserId]])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenAnswer(args => {
val userIds = args.getArgument(0).asInstanceOf[Seq[WorkbenchUserId]]
Future.successful(samUsers.filter(user => userIds.contains(WorkbenchUserId(user.id.value))).map(user => WorkbenchUserInfo(user.id.value, user.email.value)))
Expand All @@ -396,8 +396,8 @@ class NihServiceUnitSpec extends AnyFlatSpec with Matchers with BeforeAndAfterEa
val userInfo = args.getArgument(0).asInstanceOf[UserInfo]
Future.successful(linkedAccountsBySamUserId.get(WorkbenchUserId(userInfo.id)))
})
when(ecmDao.putLinkedEraAccount(any[LinkedEraAccount])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful())
when(ecmDao.deleteLinkedEraAccount(any[UserInfo])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful())
when(ecmDao.putLinkedEraAccount(any[LinkedEraAccount])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful(()))
when(ecmDao.deleteLinkedEraAccount(any[UserInfo])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenReturn(Future.successful(()))

when(ecmDao.getLinkedEraAccountForUsername(any[String])(ArgumentMatchers.eq(UserInfo(adminAccessToken, "")))).thenAnswer(args => {
val externalId = args.getArgument(0).asInstanceOf[String]
Expand All @@ -422,9 +422,9 @@ class NihServiceUnitSpec extends AnyFlatSpec with Matchers with BeforeAndAfterEa
.thenReturn(Future.successful(samUsers.map(user => user.id.value -> user.email.value).toMap))
when(thurloeDao.getAllUserValuesForKey(ArgumentMatchers.eq("linkedNihUsername"))).thenReturn(Future.successful(linkedAccountsBySamUserId.map(tup => (tup._1.value, tup._2.linkedExternalId))))
when(thurloeDao.getAllUserValuesForKey(ArgumentMatchers.eq("linkExpireTime"))).thenReturn(Future.successful(linkedAccountsBySamUserId.map(tup => (tup._1.value, (tup._2.linkExpireTime.getMillis / 1000).toString))))
when(thurloeDao.saveKeyValues(any[UserInfo], any[Map[String, String]])).thenReturn(Future.successful(Success()))
when(thurloeDao.saveKeyValues(any[String], any[WithAccessToken], any[Map[String, String]])).thenReturn(Future.successful(Success()))
when(thurloeDao.deleteKeyValue(any[String], any[String], any[WithAccessToken])).thenReturn(Future.successful(Success()))
when(thurloeDao.saveKeyValues(any[UserInfo], any[Map[String, String]])).thenReturn(Future.successful(Success(())))
when(thurloeDao.saveKeyValues(any[String], any[WithAccessToken], any[Map[String, String]])).thenReturn(Future.successful(Success(())))
when(thurloeDao.deleteKeyValue(any[String], any[String], any[WithAccessToken])).thenReturn(Future.successful(Success(())))
}

private def mockGoogleServicesDAO(): Unit = {
Expand Down

0 comments on commit 6467c38

Please sign in to comment.