### Question:
ApiManagerAuditProcessor { public ApiManagerAuditEvent getStoppedEvent(Map<String, Object> data) { ApiManagerAuditEvent event = null; try { if (ChainProcessingStatus.STOP.equals(data.get(Constants.STATUS))) { final String reason = (String) data.get(Constants.REASON); final String remoteAddress = (String) data.get(Constants.REMOTE_ADDRESS); final Ontology ontology = (Ontology) data.get(Constants.ONTOLOGY); final String method = (String) data.get(Constants.METHOD); final String query = (String) data.get(Constants.QUERY); final String body = (String) data.get(Constants.BODY); final OperationType operationType = getAuditOperationFromMethod(method); final User user = (User) data.get(Constants.USER); final String userId = getUserId(user); final String ontologyId = getOntologyId(ontology); final String operation = getOperation(operationType); final Api api = (Api) data.get(Constants.API); final Date today = new Date(); event = ApiManagerAuditEvent.builder().id(UUID.randomUUID().toString()).module(Module.APIMANAGER) .type(EventType.APIMANAGER).operationType(operation).resultOperation(ResultOperationType.ERROR) .remoteAddress(remoteAddress).message(reason).data(body).ontology(ontologyId).query(query) .timeStamp(today.getTime()).user(userId).api(api != null ? api.getIdentification() : null) .formatedTimeStamp(CalendarUtil.builder().build().convert(today)).build(); } } catch (final Exception e) { log.error("error processing stopped event ", e); } return event; }  ApiManagerAuditEvent getStoppedEvent(Map<String, Object> data); ApiManagerAuditEvent getEvent(Map<String, Object> data); OPAuditError getErrorEvent(Map<String, Object> data, Exception ex); ApiManagerAuditEvent completeEvent(ApiManagerAuditEvent event); OperationType getAuditOperationFromMethod(String method); String getUserId(User user); String getOntologyId(Ontology ontology); String getOperation(OperationType operationType);  }### Answer:
@Test public void given_getStoppedEvent_no_stop_status() { final Map<String, Object> data = new HashMap<>(); data.put(Constants.STATUS, ChainProcessingStatus.FOLLOW); final ApiManagerAuditEvent event = apiManagerAuditProcessor.getStoppedEvent(data); Assert.assertNull(event); }
@Test public void given_getStoppedEvent_stop_status() { final Map<String, Object> data = new HashMap<>(); data.put(Constants.STATUS, ChainProcessingStatus.STOP); data.put(Constants.REASON, REASON); data.put(Constants.REMOTE_ADDRESS, REMOTE_ADDRESS); data.put(Constants.ONTOLOGY, null); data.put(Constants.METHOD, ApiOperation.Type.GET.name()); data.put(Constants.QUERY, "query test"); data.put(Constants.BODY, "body test"); data.put(Constants.API, getApiTest()); data.put(Constants.USER, null); final ApiManagerAuditEvent event = apiManagerAuditProcessor.getStoppedEvent(data); Assert.assertNull(event.getOntology()); assertEquals(AuditConst.ANONYMOUS_USER, event.getUser()); assertEquals(REMOTE_ADDRESS, event.getRemoteAddress()); assertEquals(OperationType.QUERY.name(), event.getOperationType()); assertEquals(ResultOperationType.ERROR, event.getResultOperation()); assertEquals(Module.APIMANAGER, event.getModule()); assertEquals(EventType.APIMANAGER, event.getType()); assertEquals(REASON, event.getMessage()); }