### Question:
ApiRequestDataBuildUpdater implements AuditEventBuilderUpdater<ApiRequestData> { @Override public void update(AuditProto.AuditEvent.Builder auditEventBuilder, ApiRequestData eventData) { AuditProto.ApiRequestData.Builder apiRequestDataBuilder = builderProvider.getNewApiRequestDataBuilder() .setMutating(eventData.isMutating()); doIfTrue(eventData.getApiVersion(), StringUtils::isNotEmpty, apiRequestDataBuilder::setApiVersion); doIfTrue(eventData.getRequestParameters(), StringUtils::isNotEmpty, apiRequestDataBuilder::setRequestParameters); doIfTrue(eventData.getUserAgent(), StringUtils::isNotEmpty, apiRequestDataBuilder::setUserAgent); auditEventBuilder.setApiRequestData(apiRequestDataBuilder.build()); } ApiRequestDataBuildUpdater(ApiRequestDataBuilderProvider builderProvider); @Override void update(AuditProto.AuditEvent.Builder auditEventBuilder, ApiRequestData eventData); @Override Class<ApiRequestData> getType();  }### Answer:
@Test void testUpdateWhenApiVersionIsNull() { when(mockApiRequestData.getApiVersion()).thenReturn(null); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, never()).setApiVersion(any()); }
@Test void testUpdateWhenApiVersionIsEmpty() { when(mockApiRequestData.getApiVersion()).thenReturn(""); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, never()).setApiVersion(any()); }
@Test void testUpdateWhenApiVersionIsNotEmpty() { String apiVersionValue = "someApiVersion"; when(mockApiRequestData.getApiVersion()).thenReturn(apiVersionValue); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, times(1)).setApiVersion(any()); verify(mockApiRequestDataBuilder, times(1)).setApiVersion(apiVersionValue); }
@Test void testUpdateWhenRequestParameterIsNull() { when(mockApiRequestData.getRequestParameters()).thenReturn(null); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, never()).setRequestParameters(any()); }
@Test void testUpdateWhenRequestParameterIsEmpty() { when(mockApiRequestData.getRequestParameters()).thenReturn(""); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, never()).setRequestParameters(any()); }
@Test void testUpdateWhenRequestParameterIsNotEmpty() { String requestParams = "someRequestParamValue"; when(mockApiRequestData.getRequestParameters()).thenReturn(requestParams); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, times(1)).setRequestParameters(any()); verify(mockApiRequestDataBuilder, times(1)).setRequestParameters(requestParams); }
@Test void testUpdateWhenUserAgentIsNull() { when(mockApiRequestData.getUserAgent()).thenReturn(null); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, never()).setUserAgent(any()); }
@Test void testUpdateWhenUserAgentIsEmpty() { when(mockApiRequestData.getUserAgent()).thenReturn(""); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, never()).setUserAgent(any()); }
@Test void testUpdateWhenUserAgentIsNotEmpty() { String userAgentValue = "someUserAgentValue"; when(mockApiRequestData.getUserAgent()).thenReturn(userAgentValue); underTest.update(mockAuditEventBuilder, mockApiRequestData); verify(mockApiRequestDataBuilder, times(1)).setUserAgent(any()); verify(mockApiRequestDataBuilder, times(1)).setUserAgent(userAgentValue); }