use of com.sequenceiq.cloudbreak.domain.projection.StackCrnView in project cloudbreak by hortonworks.
the class StackOperationsTest method testGetWithEnvironmentCrnsByResourceCrns.
@Test
public void testGetWithEnvironmentCrnsByResourceCrns() {
StackCrnView stack1 = mock(StackCrnView.class);
when(stack1.getResourceCrn()).thenReturn("crn1");
when(stack1.getEnvironmentCrn()).thenReturn("envcrn1");
StackCrnView stack2 = mock(StackCrnView.class);
when(stack2.getResourceCrn()).thenReturn("crn2");
when(stack2.getEnvironmentCrn()).thenReturn("envcrn2");
StackCrnView stackWithoutEnv = mock(StackCrnView.class);
when(stackWithoutEnv.getResourceCrn()).thenReturn("crn3");
when(stackService.findAllByCrn(anySet())).thenReturn(List.of(stack1, stack2, stackWithoutEnv));
Map<String, Optional<String>> result = ThreadBasedUserCrnProvider.doAs("crn:altus:iam:us-west-1:123:user:456", () -> underTest.getEnvironmentCrnsByResourceCrns(List.of("crn1", "crn2", "crn3")));
Map<String, Optional<String>> expected = new LinkedHashMap<>();
expected.put("crn1", Optional.of("envcrn1"));
expected.put("crn2", Optional.of("envcrn2"));
expected.put("crn3", Optional.empty());
assertEquals(expected, result);
}
Aggregations