ActualRequirements getRequirements( RuntimeAnnotatedExecutionTrace runtimeAnnotatedExecutionTrace) { @Nullable Requirements requirements = runtimeAnnotatedExecutionTrace.getAnnotation(Requirements.class); return requirements == null ? defaultRequirements : new ActualRequirements(requirements.cpuCores(), requirements.memoryGB()); }
@Test public void getRequirementsNonNull() { RequirementsProvider requirementsProvider = new RequirementsProvider(3, 4); Requirements requirements = Mockito.mock(Requirements.class); when(requirements.cpuCores()).thenReturn(5); when(requirements.memoryGB()).thenReturn(6); RuntimeAnnotatedExecutionTrace executionTrace = Mockito.mock(RuntimeAnnotatedExecutionTrace.class); when(executionTrace.getAnnotation(Requirements.class)).thenReturn(requirements); Assert.assertEquals( requirementsProvider.getRequirements(executionTrace), new ActualRequirements(5, 6)); }