CameraPermissionRequirement implements Requirement { @NonNull @Override public RequirementReport check() { boolean result = true; String details = ""; int check = mContext.getPackageManager().checkPermission(Manifest.permission.CAMERA, mContext.getPackageName()); if (check != PackageManager.PERMISSION_GRANTED) { result = false; details = "Camera permission was not granted"; } return new RequirementReport(getId(), result, details); } CameraPermissionRequirement(Context context); @NonNull @Override RequirementId getId(); @NonNull @Override RequirementReport check();  }
@Test public void should_reportUnfulfilled_ifCameraPermission_wasNotGranted() { final Context context = getContextForCameraPermission(false); final CameraPermissionRequirement requirement = new CameraPermissionRequirement(context); assertThat(requirement.check().isFulfilled()).isFalse(); }
@Test public void should_reportFulfilled_ifCameraPermission_wasGranted() { final Context context = getContextForCameraPermission(true); final CameraPermissionRequirement requirement = new CameraPermissionRequirement(context); assertThat(requirement.check().isFulfilled()).isTrue(); }