Search in sources :

Example 1 with MockCreationValidator

use of org.mockito.internal.util.MockCreationValidator in project j2objc by google.

the class MockSettingsImpl method validatedSettings.

private static <T> CreationSettings<T> validatedSettings(Class<T> typeToMock, CreationSettings<T> source) {
    MockCreationValidator validator = new MockCreationValidator();
    validator.validateType(typeToMock);
    validator.validateExtraInterfaces(typeToMock, source.getExtraInterfaces());
    validator.validateMockedType(typeToMock, source.getSpiedInstance());
    //TODO SF - add this validation and also add missing coverage
    //        validator.validateDelegatedInstance(classToMock, settings.getDelegatedInstance());
    CreationSettings<T> settings = new CreationSettings<T>(source);
    settings.setMockName(new MockNameImpl(source.getName(), typeToMock));
    settings.setTypeToMock(typeToMock);
    settings.setExtraInterfaces(prepareExtraInterfaces(source));
    return settings;
}
Also used : MockCreationSettings(org.mockito.mock.MockCreationSettings) CreationSettings(org.mockito.internal.creation.settings.CreationSettings) MockCreationValidator(org.mockito.internal.util.MockCreationValidator) MockNameImpl(org.mockito.internal.util.MockNameImpl)

Example 2 with MockCreationValidator

use of org.mockito.internal.util.MockCreationValidator in project mockito by mockito.

the class MockSettingsImpl method validatedSettings.

private static <T> CreationSettings<T> validatedSettings(Class<T> typeToMock, CreationSettings<T> source) {
    MockCreationValidator validator = new MockCreationValidator();
    validator.validateType(typeToMock);
    validator.validateExtraInterfaces(typeToMock, source.getExtraInterfaces());
    validator.validateMockedType(typeToMock, source.getSpiedInstance());
    // TODO SF - add this validation and also add missing coverage
    // validator.validateDelegatedInstance(classToMock, settings.getDelegatedInstance());
    validator.validateConstructorUse(source.isUsingConstructor(), source.getSerializableMode());
    // TODO SF - I don't think we really need CreationSettings type
    // TODO do we really need to copy the entire settings every time we create mock object? it
    // does not seem necessary.
    CreationSettings<T> settings = new CreationSettings<T>(source);
    settings.setMockName(new MockNameImpl(source.getName(), typeToMock, false));
    settings.setTypeToMock(typeToMock);
    settings.setExtraInterfaces(prepareExtraInterfaces(source));
    return settings;
}
Also used : MockCreationSettings(org.mockito.mock.MockCreationSettings) CreationSettings(org.mockito.internal.creation.settings.CreationSettings) MockCreationValidator(org.mockito.internal.util.MockCreationValidator) MockNameImpl(org.mockito.internal.util.MockNameImpl)

Aggregations

CreationSettings (org.mockito.internal.creation.settings.CreationSettings)2 MockCreationValidator (org.mockito.internal.util.MockCreationValidator)2 MockNameImpl (org.mockito.internal.util.MockNameImpl)2 MockCreationSettings (org.mockito.mock.MockCreationSettings)2