Java Code Examples for org.mockito.quality.Strictness#LENIENT
The following examples show how to use
org.mockito.quality.Strictness#LENIENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterCreationEnvironmentValidatorTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@ParameterizedTest(name = "{0}") @MethodSource("autoTlsConfigurations") @MockitoSettings(strictness = Strictness.LENIENT) void testAutoTlsConfigurations(String testName, boolean cmAutoTls, boolean providerAutoTls, boolean expectedHasErrors) { // GIVEN Stack stack = getStack(); User user = getUser(); ClusterV4Request clusterRequest = new ClusterV4Request(); ClouderaManagerV4Request cmRequest = new ClouderaManagerV4Request(); cmRequest.setEnableAutoTls(cmAutoTls); clusterRequest.setCm(cmRequest); DetailedEnvironmentResponse environment = getEnvironmentResponse(); when(platformParameters.isAutoTlsSupported()).thenReturn(providerAutoTls); // WHEN ValidationResult actualResult = underTest.validate(clusterRequest, stack, environment, user); // THEN assertEquals(expectedHasErrors, actualResult.hasError()); if (expectedHasErrors) { assertEquals(1, actualResult.getErrors().size()); assertTrue(actualResult.getErrors().contains("AutoTLS is not supported by 'aws' platform!")); } }
Example 2
Source File: AwsVolumeResourceBuilderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void buildTestWhenAttachedVolumesOnlyAndEncryptionWithDefaultKeyAndSnapshotError() { Group group = createGroup(List.of(createVolume(TYPE_GP2)), Map.ofEntries(entry(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED, true), entry(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.DEFAULT.name()), entry(AwsInstanceTemplate.FAST_EBS_ENCRYPTION_ENABLED, false))); when(encryptedSnapshotService.isEncryptedVolumeRequested(group)).thenReturn(true); when(encryptedSnapshotService.createSnapshotIfNeeded(authenticatedContext, cloudStack, group, resourceNotifier)).thenReturn(Optional.empty()); CloudConnectorException exception = assertThrows(CloudConnectorException.class, () -> underTest.build(awsContext, PRIVATE_ID, authenticatedContext, group, List.of(createVolumeSet(List.of(createVolumeForVolumeSet(TYPE_GP2)))), cloudStack)); assertThat(exception.getMessage()).contains("Failed to create EBS encrypted volume on stack:"); }
Example 3
Source File: CreateExternalDatabaseHandlerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@ParameterizedTest @ValueSource(classes = { UserBreakException.class, PollerStoppedException.class, PollerException.class, Exception.class}) @MockitoSettings(strictness = Strictness.LENIENT) void acceptCatchErrors(Class<? extends Exception> exceptionClass) { doAnswer(a -> { throw exceptionClass.getDeclaredConstructor().newInstance(); }).when(provisionService).provisionDatabase(any(), any(DatabaseAvailabilityType.class), any()); DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse(); environment.setCloudPlatform("cloudplatform"); when(environmentClientService.getByCrn(anyString())).thenReturn(environment); Stack stack = buildStack(DatabaseAvailabilityType.HA); CreateExternalDatabaseRequest request = new CreateExternalDatabaseRequest(STACK_ID, "selector", "resourceName", "crn", stack); Event<CreateExternalDatabaseRequest> event = new Event<>(EVENT_HEADERS, request); underTest.accept(event); verify(provisionService).provisionDatabase(any(), eq(DatabaseAvailabilityType.HA), eq(environment)); verify(environmentValidator).checkValidEnvironment(eq(STACK_NAME), eq(DatabaseAvailabilityType.HA), eq(environment)); verify(stackUpdaterService).updateStatus(eq(STACK_ID), eq(DetailedStackStatus.EXTERNAL_DATABASE_CREATION_IN_PROGRESS), eq(ResourceEvent.CLUSTER_EXTERNAL_DATABASE_CREATION_STARTED), eq("External database creation in progress")); verify(stackUpdaterService, never()).updateStatus(eq(STACK_ID), eq(DetailedStackStatus.PROVISION_REQUESTED), eq(ResourceEvent.CLUSTER_EXTERNAL_DATABASE_CREATION_FINISHED), anyString()); verify(eventBus).notify(eq("CreateExternalDatabaseFailed"), any(Event.class)); }
Example 4
Source File: TerminateExternalDatabaseHandlerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@ParameterizedTest @ValueSource(classes = { UserBreakException.class, PollerStoppedException.class, PollerException.class, Exception.class}) @MockitoSettings(strictness = Strictness.LENIENT) void acceptCatchErrors(Class<? extends Exception> exceptionClass) { doAnswer(a -> { throw exceptionClass.getDeclaredConstructor().newInstance(); }).when(terminationService).terminateDatabase(any(), any(DatabaseAvailabilityType.class), any(), anyBoolean()); DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse(); environment.setCloudPlatform("cloudplatform"); when(environmentClientService.getByCrn(anyString())).thenReturn(environment); Stack stack = buildStack(DatabaseAvailabilityType.HA); TerminateExternalDatabaseRequest request = new TerminateExternalDatabaseRequest(STACK_ID, "selector", "resourceName", "crn", stack, true); Event<TerminateExternalDatabaseRequest> event = new Event<>(EVENT_HEADERS, request); underTest.accept(event); verify(terminationService).terminateDatabase(any(), eq(DatabaseAvailabilityType.HA), eq(environment), eq(true)); verify(stackUpdaterService).updateStatus(eq(STACK_ID), eq(DetailedStackStatus.EXTERNAL_DATABASE_DELETION_IN_PROGRESS), eq(ResourceEvent.CLUSTER_EXTERNAL_DATABASE_DELETION_STARTED), eq("External database deletion in progress")); verify(stackUpdaterService, never()).updateStatus(eq(STACK_ID), eq(DetailedStackStatus.PROVISION_REQUESTED), eq(ResourceEvent.CLUSTER_EXTERNAL_DATABASE_CREATION_FINISHED), anyString()); verify(eventBus).notify(eq("TerminateExternalDatabaseFailed"), any(Event.class)); }
Example 5
Source File: AwsPublicKeyConnectorTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void platform() { assertThat(underTest.platform()).isEqualTo(AwsConstants.AWS_PLATFORM); }
Example 6
Source File: AwsPublicKeyConnectorTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void variant() { assertThat(underTest.variant()).isEqualTo(AwsConstants.AWS_VARIANT); }
Example 7
Source File: PublicKeyCreationHandlerTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void selector() { doAnswer(i -> null).when(eventSender).sendEvent(baseNamedFlowEvent.capture(), any(Headers.class)); assertThat(underTest.selector()).isEqualTo("CREATE_PUBLICKEY_EVENT"); }
Example 8
Source File: S3GuardTableDeleteHandlerTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void selector() { assertEquals(DELETE_S3GUARD_TABLE_EVENT.selector(), underTest.selector()); }
Example 9
Source File: DataHubClusterDeletionHandlerTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void selector() { assertThat(underTest.selector()).isEqualTo("DELETE_DATAHUB_CLUSTERS_EVENT"); }
Example 10
Source File: PublicKeyDeleteHandlerTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void selector() { assertThat(underTest.selector()).isEqualTo("DELETE_PUBLICKEY_EVENT"); }
Example 11
Source File: DataLakeClustersDeleteHandlerTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Test @MockitoSettings(strictness = Strictness.LENIENT) void selector() { assertThat(underTest.selector()).isEqualTo("DELETE_DATALAKE_CLUSTERS_EVENT"); }