use of org.mockito.mock.MockName in project powermock by powermock.
the class MockCreatorTest method testMock_shouldReturnClassNameWhenSettingsHaveNoName.
@Test
public void testMock_shouldReturnClassNameWhenSettingsHaveNoName() throws NoSuchMethodException, SecurityException {
final MockSettingsImpl<List<?>> settings = new MockSettingsImpl<List<?>>();
final List<?> result = DefaultMockCreator.mock(List.class, false, false, null, settings, List.class.getMethod("add", Object.class));
final MockName mockName = MockUtil.getMockName(result);
assertNotNull(mockName);
assertEquals("list", mockName.toString());
}
use of org.mockito.mock.MockName in project powermock by powermock.
the class MockCreatorTest method testMock_shouldReturnMockNameWhenSettingsHaveName.
@Test
public void testMock_shouldReturnMockNameWhenSettingsHaveName() throws NoSuchMethodException, SecurityException {
final MockSettingsImpl<List<?>> settings = new MockSettingsImpl<List<?>>();
settings.name("mylist");
final List<?> result = DefaultMockCreator.mock(List.class, false, false, null, settings, List.class.getMethod("add", Object.class));
final MockName mockName = MockUtil.getMockName(result);
assertNotNull(mockName);
assertEquals("mylist", mockName.toString());
}
use of org.mockito.mock.MockName in project powermock by powermock.
the class MockCreatorTestCase method should_return_mock_name_when_settings_have_name.
@Test
public void should_return_mock_name_when_settings_have_name() throws NoSuchMethodException, SecurityException {
final String definedMockName = "my-list";
final MockSettings settings = Mockito.withSettings().name(definedMockName);
final List<?> result = createMock(settings);
final MockName mockName = getMockName(result);
assertThat(mockName.toString()).as("Mock name is configured").isEqualTo(definedMockName);
}
use of org.mockito.mock.MockName in project powermock by powermock.
the class DefaultMockCreatorTest method testMock_shouldReturnMockNameWhenSettingsHaveName.
@Test
public void testMock_shouldReturnMockNameWhenSettingsHaveName() throws NoSuchMethodException, SecurityException {
final MockSettingsImpl<List<?>> settings = new MockSettingsImpl<List<?>>();
settings.name("mylist");
final List<?> result = DefaultMockCreator.mock(List.class, false, false, null, settings, List.class.getMethod("add", Object.class));
final MockName mockName = util.getMockName(result);
assertNotNull(mockName);
assertEquals("mylist", mockName.toString());
}
use of org.mockito.mock.MockName in project powermock by powermock.
the class DefaultMockCreatorTest method testMock_shouldReturnClassNameWhenSettingsHaveNoName.
@Test
public void testMock_shouldReturnClassNameWhenSettingsHaveNoName() throws NoSuchMethodException, SecurityException {
final MockSettingsImpl<List<?>> settings = new MockSettingsImpl<List<?>>();
final List<?> result = DefaultMockCreator.mock(List.class, false, false, null, settings, List.class.getMethod("add", Object.class));
final MockName mockName = util.getMockName(result);
assertNotNull(mockName);
assertEquals("list", mockName.toString());
}
Aggregations