Skip to content

Commit 7a67988

Browse files
jreynard-codeLeopold-Cramer
authored andcommitted
Remove timestamp nested test from Organization
1 parent cb903cc commit 7a67988

File tree

1 file changed

+44
-54
lines changed

1 file changed

+44
-54
lines changed

organization/src/integrationTest/kotlin/com/cosmotech/organization/service/OrganizationServiceIntegrationTest.kt

Lines changed: 44 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class OrganizationServiceIntegrationTest : CsmRedisTestBase() {
8181
@Autowired lateinit var organizationApiService: OrganizationApiServiceInterface
8282

8383
@Autowired lateinit var csmPlatformProperties: CsmPlatformProperties
84+
var startTime: Long = 0
8485

8586
val defaultName = "[email protected]"
8687

@@ -96,6 +97,7 @@ class OrganizationServiceIntegrationTest : CsmRedisTestBase() {
9697
every { getCurrentAuthenticatedUserName(csmPlatformProperties) } returns "my.account-tester"
9798
every { getCurrentAuthenticatedRoles(any()) } returns listOf()
9899
rediSearchIndexer.createIndexFor(Organization::class.java)
100+
startTime = Instant.now().toEpochMilli()
99101
}
100102

101103
@Nested
@@ -2132,73 +2134,61 @@ class OrganizationServiceIntegrationTest : CsmRedisTestBase() {
21322134
}
21332135
}
21342136

2135-
@Nested
2136-
inner class OrganizationTimeStampsTest() {
2137-
private var startTime: Long = 0
2138-
private var organizationSaved: Organization = mockk<Organization>()
2137+
@Test
2138+
fun `assert timestamps are functional for base CRUD`() {
2139+
val organizationSaved =
2140+
organizationApiService.createOrganization(
2141+
makeSimpleOrganizationCreateRequest("organization"))
2142+
assertTrue(organizationSaved.createInfo.timestamp > startTime)
2143+
assertEquals(organizationSaved.createInfo, organizationSaved.updateInfo)
21392144

2140-
@BeforeEach
2141-
fun init() {
2142-
startTime = Instant.now().toEpochMilli()
2143-
Thread.sleep(1)
2144-
organizationSaved =
2145-
organizationApiService.createOrganization(
2146-
makeSimpleOrganizationCreateRequest("organization"))
2147-
}
2145+
val updateTime = Instant.now().toEpochMilli()
2146+
val organizationUpdated =
2147+
organizationApiService.updateOrganization(
2148+
organizationSaved.id, OrganizationUpdateRequest("organizationUpdated"))
21482149

2149-
@Test
2150-
fun `assert timestamps are functional for base CRUD`() {
2151-
assertTrue(organizationSaved.createInfo.timestamp > startTime)
2152-
assertEquals(organizationSaved.createInfo, organizationSaved.updateInfo)
2150+
assertTrue { updateTime < organizationUpdated.updateInfo.timestamp }
2151+
assertEquals(organizationSaved.createInfo, organizationUpdated.createInfo)
2152+
assertTrue { organizationSaved.createInfo.timestamp < organizationUpdated.updateInfo.timestamp }
2153+
assertTrue { organizationSaved.updateInfo.timestamp < organizationUpdated.updateInfo.timestamp }
21532154

2154-
val updateTime = Instant.now().toEpochMilli()
2155-
val organizationUpdated =
2156-
organizationApiService.updateOrganization(
2157-
organizationSaved.id, OrganizationUpdateRequest("organizationUpdated"))
2155+
val organizationFetched = organizationApiService.getOrganization(organizationSaved.id)
21582156

2159-
assertTrue { updateTime < organizationUpdated.updateInfo.timestamp }
2160-
assertEquals(organizationSaved.createInfo, organizationSaved.createInfo)
2161-
assertTrue {
2162-
organizationSaved.createInfo.timestamp < organizationUpdated.updateInfo.timestamp
2163-
}
2164-
assertTrue {
2165-
organizationSaved.updateInfo.timestamp < organizationUpdated.updateInfo.timestamp
2166-
}
2167-
2168-
val organizationFetched = organizationApiService.getOrganization(organizationSaved.id)
2157+
assertEquals(organizationUpdated.createInfo, organizationFetched.createInfo)
2158+
assertEquals(organizationUpdated.updateInfo, organizationFetched.updateInfo)
2159+
}
21692160

2170-
assertEquals(organizationUpdated.createInfo, organizationFetched.createInfo)
2171-
assertEquals(organizationUpdated.updateInfo, organizationFetched.updateInfo)
2172-
}
2161+
@Test
2162+
fun `assert timestamps are functional for RBAC CRUD`() {
2163+
val organizationSaved =
2164+
organizationApiService.createOrganization(
2165+
makeSimpleOrganizationCreateRequest("organization"))
2166+
organizationApiService.createOrganizationAccessControl(
2167+
organizationSaved.id, OrganizationAccessControl("newUser", ROLE_USER))
21732168

2174-
@Test
2175-
fun `assert timestamps are functional for RBAC CRUD`() {
2176-
organizationApiService.createOrganizationAccessControl(
2177-
organizationSaved.id, OrganizationAccessControl("newUser", ROLE_USER))
2178-
val rbacAdded = organizationApiService.getOrganization(organizationSaved.id)
2169+
val rbacAdded = organizationApiService.getOrganization(organizationSaved.id)
21792170

2180-
assertEquals(organizationSaved.createInfo, rbacAdded.createInfo)
2181-
assertTrue { organizationSaved.updateInfo.timestamp < rbacAdded.updateInfo.timestamp }
2171+
assertEquals(organizationSaved.createInfo, rbacAdded.createInfo)
2172+
assertTrue { organizationSaved.updateInfo.timestamp < rbacAdded.updateInfo.timestamp }
21822173

2183-
organizationApiService.updateOrganizationAccessControl(
2184-
organizationSaved.id, "newUser", OrganizationRole(ROLE_VIEWER))
2185-
val rbacUpdated = organizationApiService.getOrganization(organizationSaved.id)
2174+
organizationApiService.updateOrganizationAccessControl(
2175+
organizationSaved.id, "newUser", OrganizationRole(ROLE_VIEWER))
2176+
val rbacUpdated = organizationApiService.getOrganization(organizationSaved.id)
21862177

2187-
assertEquals(rbacAdded.createInfo, rbacUpdated.createInfo)
2188-
assertTrue { rbacAdded.updateInfo.timestamp < rbacUpdated.updateInfo.timestamp }
2178+
assertEquals(rbacAdded.createInfo, rbacUpdated.createInfo)
2179+
assertTrue { rbacAdded.updateInfo.timestamp < rbacUpdated.updateInfo.timestamp }
21892180

2190-
organizationApiService.getOrganizationAccessControl(organizationSaved.id, "newUser")
2191-
val rbacFetched = organizationApiService.getOrganization(organizationSaved.id)
2181+
organizationApiService.getOrganizationAccessControl(organizationSaved.id, "newUser")
2182+
val rbacFetched = organizationApiService.getOrganization(organizationSaved.id)
21922183

2193-
assertEquals(rbacUpdated.createInfo, rbacFetched.createInfo)
2194-
assertEquals(rbacUpdated.updateInfo, rbacFetched.updateInfo)
2184+
assertEquals(rbacUpdated.createInfo, rbacFetched.createInfo)
2185+
assertEquals(rbacUpdated.updateInfo, rbacFetched.updateInfo)
21952186

2196-
organizationApiService.deleteOrganizationAccessControl(organizationSaved.id, "newUser")
2197-
val rbacDeleted = organizationApiService.getOrganization(organizationSaved.id)
2187+
organizationApiService.deleteOrganizationAccessControl(organizationSaved.id, "newUser")
2188+
val rbacDeleted = organizationApiService.getOrganization(organizationSaved.id)
21982189

2199-
assertEquals(rbacFetched.createInfo, rbacDeleted.createInfo)
2200-
assertTrue { rbacFetched.updateInfo.timestamp < rbacDeleted.updateInfo.timestamp }
2201-
}
2190+
assertEquals(rbacFetched.createInfo, rbacDeleted.createInfo)
2191+
assertTrue { rbacFetched.updateInfo.timestamp < rbacDeleted.updateInfo.timestamp }
22022192
}
22032193

22042194
private fun testFindAllWithRBAC(

0 commit comments

Comments
 (0)