DeviceMemoryRequirement implements Requirement { @VisibleForTesting boolean sufficientMemoryAvailable(final Size photoSize) { final Runtime runtime = Runtime.getRuntime(); return sufficientMemoryAvailable(runtime, photoSize); } DeviceMemoryRequirement(final CameraHolder cameraHolder); @NonNull @Override RequirementId getId(); @NonNull @Override RequirementReport check();  }
@Test public void should_checkIfPictureSize_fitsIntoUnusedMemory() { CameraHolder cameraHolder = getCameraHolder(null); DeviceMemoryRequirement requirement = new DeviceMemoryRequirement(cameraHolder); Runtime runtime = getRuntimeMock(28, 1, 32); assertThat(requirement.sufficientMemoryAvailable(runtime, new Size(800, 600))).isTrue(); assertThat(requirement.sufficientMemoryAvailable(runtime, new Size(1024, 768))).isFalse(); }