use of com.netsuite.webservices.test.platform.messages.DeleteResponse in project components by Talend.
the class NetSuiteClientServiceTest method testRetrying.
@Test
public void testRetrying() throws Exception {
clientService.setRetryCount(3);
clientService.setRetryInterval(1);
clientService.login();
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), typeDesc).composeObject();
final DeleteResponse response = new DeleteResponse();
response.setWriteResponse(createSuccessWriteResponse());
final AtomicInteger counter = new AtomicInteger(3);
when(port.delete(notNull(DeleteRequest.class))).thenAnswer(new Answer<DeleteResponse>() {
@Override
public DeleteResponse answer(InvocationOnMock invocation) throws Throwable {
if (counter.decrementAndGet() > 0) {
com.netsuite.webservices.test.platform.faults.InvalidSessionFault faultInfo = new com.netsuite.webservices.test.platform.faults.InvalidSessionFault();
faultInfo.setCode(FaultCodeType.SESSION_TIMED_OUT);
faultInfo.setMessage("Session timed out");
InvalidSessionFault fault = new InvalidSessionFault(faultInfo.getMessage(), faultInfo);
throw fault;
}
return response;
}
});
StopWatch stopWatch = new StopWatch();
stopWatch.start();
clientService.delete(recordRef);
stopWatch.stop();
verify(port, times(3)).login(notNull(LoginRequest.class));
verify(port, times(3)).delete(notNull(DeleteRequest.class));
assertTrue(stopWatch.getTime() >= 3 * clientService.getRetryInterval() * 1000);
}
use of com.netsuite.webservices.test.platform.messages.DeleteResponse in project components by Talend.
the class NetSuiteClientServiceTest method testDelete.
@Test
public void testDelete() throws Exception {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), typeDesc).composeObject();
DeleteResponse response = new DeleteResponse();
response.setWriteResponse(createSuccessWriteResponse());
when(port.delete(notNull(DeleteRequest.class))).thenReturn(response);
clientService.delete(recordRef);
verify(port, times(1)).login(notNull(LoginRequest.class));
verify(port, times(1)).delete(notNull(DeleteRequest.class));
NsWriteResponse writeResponse = clientService.delete(null);
assertNull(writeResponse.getStatus());
assertNull(writeResponse.getRef());
}
use of com.netsuite.webservices.test.platform.messages.DeleteResponse in project components by Talend.
the class NetSuiteClientServiceTest method testLogin.
@Test
public void testLogin() throws Exception {
clientService.login();
verify(port, times(1)).login(argThat(new AssertMatcher<LoginRequest>() {
@Override
protected void doAssert(LoginRequest request) throws Exception {
assertNotNull(request);
Passport passport = request.getPassport();
assertNotNull(passport);
}
}));
// Verify that logging in not performed for already logged in client
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), typeDesc).composeObject();
DeleteResponse response = new DeleteResponse();
response.setWriteResponse(createSuccessWriteResponse());
when(port.delete(notNull(DeleteRequest.class))).thenReturn(response);
clientService.delete(recordRef);
verify(port, times(1)).login(any(LoginRequest.class));
}
Aggregations