### Question:
TenantIdAccessor { public long getTenantIdFromRequestOrCookie() throws ServletException { String tenantId = request.getTenantId(); if (tenantId == null) { tenantId = portalCookies.getTenantCookieFromRequest(request.asHttpServletRequest()); } if (tenantId == null) { return getDefaultTenantId(); } return parseTenantId(tenantId); } TenantIdAccessor(HttpServletRequestAccessor request); long getRequestedTenantId(); long ensureTenantId(); long getDefaultTenantId(); long getTenantIdFromRequestOrCookie();  }### Answer:
@Test public void should_retrieve_tenant_id_from_request_when_set_in_request_parameters() throws Exception { request.setCookies(new Cookie("bonita.tenant", "123")); doReturn("5").when(requestAccessor).getTenantId(); long tenantId = tenantIdAccessor.getTenantIdFromRequestOrCookie(); assertThat(tenantId).isEqualTo(5); }
@Test public void should_retrieve_tenant_id_from_cookies_when_not_set_in_request_parameters() throws Exception { request.setCookies(new Cookie("bonita.tenant", "123")); long tenantId = tenantIdAccessor.getTenantIdFromRequestOrCookie(); assertThat(tenantId).isEqualTo(123); }