Java Code Examples for org.powermock.api.mockito.PowerMockito#verifyNew()
The following examples show how to use
org.powermock.api.mockito.PowerMockito#verifyNew() .
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: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void readValue() throws Exception { // Given PowerMockito.mockStatic(QueryReadValue.class); Database database = new Database(); QueryReadValue query = Mockito.spy(new QueryReadValue(database, "/test")); PowerMockito.whenNew(QueryReadValue.class).withAnyArguments().thenReturn(query); // When database.inReference("/test").readValue(String.class).subscribe(); // Then // verify(mapConverter, VerificationModeFactory.times(1)).convert(any(Map.class), any(Class.class)); PowerMockito.verifyNew(QueryReadValue.class); // TODO - verify converter }
Example 2
Source File: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void onDataChange() throws Exception { // Given PowerMockito.mockStatic(QueryOnDataChange.class); QueryOnDataChange query = PowerMockito.mock(QueryOnDataChange.class); PowerMockito.whenNew(QueryOnDataChange.class).withAnyArguments().thenReturn(query); when(query.with(Mockito.nullable(Array.class))).thenReturn(query); when(query.with(Mockito.nullable(OrderByClause.class))).thenReturn(query); when(query.withArgs(Mockito.any(), Mockito.any())).thenReturn(query); Database database = new Database(); // When database.inReference("/test").onDataChange(Map.class).subscribe(); // Then // verify(mapConverter, VerificationModeFactory.times(1)).convert(any(Map.class), any(Class.class)); PowerMockito.verifyNew(QueryOnDataChange.class); // TODO - verify converter }
Example 3
Source File: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void updateChildren() throws Exception { // Given PowerMockito.mockStatic(QueryUpdateChildren.class); Database database = new Database(); QueryUpdateChildren query = PowerMockito.spy(new QueryUpdateChildren(database, "/test")); PowerMockito.whenNew(QueryUpdateChildren.class).withAnyArguments().thenReturn(query); when(query.withArgs(Mockito.any())).thenReturn(query); Map data = Mockito.mock(Map.class); // When database.inReference("/test").updateChildren(data); // Then PowerMockito.verifyNew(QueryUpdateChildren.class); }
Example 4
Source File: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void transaction() throws Exception { // Given PowerMockito.mockStatic(QueryRunTransaction.class); Database database = new Database(); QueryRunTransaction query = PowerMockito.mock(QueryRunTransaction.class); PowerMockito.whenNew(QueryRunTransaction.class).withAnyArguments().thenReturn(query); when(query.withArgs(Mockito.any())).thenReturn(query); Function transactionFunction = Mockito.mock(Function.class); Class dataType = String.class; // When database.inReference("/test").transaction(dataType, transactionFunction); // Then PowerMockito.verifyNew(QueryRunTransaction.class); }
Example 5
Source File: DeployOvfTemplateActionTest.java From cs-actions with Apache License 2.0 | 6 votes |
@Test public void testSuccessDeployTemplate() throws Exception { prepareForTests(); Mockito.doNothing().when(service).deployOvfTemplate(any(HttpInputs.class), any(VmInputs.class), anyString(), anyMap(), anyMap()); Map<String, String> result = action.deployTemplate("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", OVF_NETWORK_JS_VALUES, NET_PORT_GROUP_JS_VALUES, OVF_PROP_KEY_JS_VALUES, OVF_PROP_VALUE_JS_VALUES, "", null); Mockito.verify(service).deployOvfTemplate(any(HttpInputs.class), any(VmInputs.class), anyString(), anyMap(), anyMap()); assertEquals(ReturnCodes.SUCCESS, result.get(Outputs.RETURN_CODE)); assertEquals(SUCCESSFULLY_DEPLOYED, result.get(Outputs.RETURN_RESULT)); verifyStatic(); OvfUtils.getOvfMappings(OVF_NETWORK_JS_VALUES, NET_PORT_GROUP_JS_VALUES); OvfUtils.getOvfMappings(OVF_PROP_KEY_JS_VALUES, OVF_PROP_VALUE_JS_VALUES); PowerMockito.verifyNew(DeployOvfTemplateService.class); }
Example 6
Source File: DeployOvfTemplateActionTest.java From cs-actions with Apache License 2.0 | 6 votes |
@Test public void testFailureDeployTemplate() throws Exception { prepareForTests(); Mockito.doThrow(new Exception(OPERATION_FAILED)).when(service).deployOvfTemplate(any(HttpInputs.class), any(VmInputs.class), anyString(), anyMap(), anyMap()); Map<String, String> result = action.deployTemplate("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", OVF_NETWORK_JS_VALUES, NET_PORT_GROUP_JS_VALUES, OVF_PROP_KEY_JS_VALUES, OVF_PROP_VALUE_JS_VALUES, "", null); Mockito.verify(service).deployOvfTemplate(any(HttpInputs.class), any(VmInputs.class), anyString(), anyMap(), anyMap()); assertEquals(ReturnCodes.FAILURE, result.get(Outputs.RETURN_CODE)); assertEquals(OPERATION_FAILED, result.get(Outputs.RETURN_RESULT)); assertTrue(StringUtilities.contains(result.get(Outputs.RETURN_RESULT), OPERATION_FAILED)); verifyStatic(); OvfUtils.getOvfMappings(OVF_NETWORK_JS_VALUES, NET_PORT_GROUP_JS_VALUES); OvfUtils.getOvfMappings(OVF_PROP_KEY_JS_VALUES, OVF_PROP_VALUE_JS_VALUES); PowerMockito.verifyNew(DeployOvfTemplateService.class); }
Example 7
Source File: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 5 votes |
@Test public void onConnect() throws Exception { // Given PowerMockito.mockStatic(QueryConnectionStatus.class); Database database = new Database(); QueryConnectionStatus query = Mockito.spy(new QueryConnectionStatus(database, "/test")); PowerMockito.whenNew(QueryConnectionStatus.class).withAnyArguments().thenReturn(query); when(query.withArgs(Mockito.any())).thenReturn(query); // When database.onConnect().subscribe(); // Then PowerMockito.verifyNew(QueryConnectionStatus.class); }
Example 8
Source File: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 5 votes |
@Test public void setValue() throws Exception { // Given PowerMockito.mockStatic(QuerySetValue.class); Database database = new Database(); QuerySetValue query = PowerMockito.spy(new QuerySetValue(database, "/test")); PowerMockito.whenNew(QuerySetValue.class).withAnyArguments().thenReturn(query); when(query.withArgs(Mockito.any())).thenReturn(query); // When Promise promise = Mockito.spy(database.inReference("/test").setValue("").subscribe()); // Then PowerMockito.verifyNew(QuerySetValue.class); }
Example 9
Source File: DatabaseTest.java From gdx-fireapp with Apache License 2.0 | 5 votes |
@Test public void removeValue() throws Exception { // Given PowerMockito.mockStatic(QueryRemoveValue.class); Database database = new Database(); QueryRemoveValue query = PowerMockito.mock(QueryRemoveValue.class); PowerMockito.whenNew(QueryRemoveValue.class).withAnyArguments().thenReturn(query); when(query.withArgs(Mockito.any())).thenReturn(query); // When Promise promise = Mockito.spy(database.inReference("/test").removeValue()); // Then PowerMockito.verifyNew(QueryRemoveValue.class); }