Java Code Examples for org.assertj.core.util.Strings#isNullOrEmpty()
The following examples show how to use
org.assertj.core.util.Strings#isNullOrEmpty() .
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: PropertiesHandler.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
public Long getLongTestParam(String property, Long defaultVal) { String value = getTestParam(property); if (Strings.isNullOrEmpty(value)) { return defaultVal; } return Long.parseLong(value); }
Example 2
Source File: PropertiesHandler.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
public int getIntTestParam(String property, int defaultVal) { String value = getTestParam(property); if (Strings.isNullOrEmpty(value)) { return defaultVal; } return Integer.parseInt(value); }
Example 3
Source File: PropertiesHandler.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
public String getClientTestParam(String property, int num, String defaultVal) { String retrievedValue = getTestParam(String.format(clientPattern, property, num)); if (Strings.isNullOrEmpty(retrievedValue)) { return defaultVal; } return retrievedValue; }
Example 4
Source File: ConsoleIndex.java From eagle with Apache License 2.0 | 5 votes |
@ResponseBody @RequestMapping(value = "/user", method = RequestMethod.HEAD) public void getLoginUser(HttpServletResponse response) { UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); String userName = userDetails.getUsername(); if (Strings.isNullOrEmpty(userName)) { AuthenticatUtil.needAuthenticate(response); return; } AuthenticatUtil.authenticateSuccess(response, userName); }
Example 5
Source File: InterfaceApiServiceImpl.java From eagle with Apache License 2.0 | 5 votes |
@Override public ClientServiceInfo getClientConfig(String serviceName, String protocol, String host) { String clientConfigJson = regCenter.getDirectly(String.format(REF, serviceName, protocol, host)); if (Strings.isNullOrEmpty(clientConfigJson)) { return null; } MergeConfig config = MergeConfig.decode(clientConfigJson); ClientServiceInfo serviceInfo = new ClientServiceInfo(); getServiceInfo(ClientServiceInfo.class, config, serviceInfo); return serviceInfo; }
Example 6
Source File: InterfaceApiServiceImpl.java From eagle with Apache License 2.0 | 5 votes |
@Override public ServerServiceInfo getServerConfig(String serviceName, String protocol, String host) { String serverConfigJson = regCenter.getDirectly(String.format(SERVICE, serviceName, protocol, host)); if (Strings.isNullOrEmpty(serverConfigJson)) { return null; } MergeConfig config = MergeConfig.decode(serverConfigJson); ServerServiceInfo serviceInfo = new ServerServiceInfo(); getServiceInfo(ServerServiceInfo.class, config, serviceInfo); return serviceInfo; }
Example 7
Source File: AuthServiceTest.java From armeria with Apache License 2.0 | 5 votes |
private static HttpRequestBase oauth1aGetRequest( String path, OAuth1aToken oAuth1aToken, AsciiString header) { final HttpGet request = new HttpGet(server.httpUri().resolve(path)); final StringBuilder authorization = new StringBuilder("OAuth "); final String realm = oAuth1aToken.realm(); if (!Strings.isNullOrEmpty(realm)) { authorization.append("realm=\""); authorization.append(realm); authorization.append("\","); } authorization.append("oauth_consumer_key=\""); authorization.append(oAuth1aToken.consumerKey()); authorization.append("\",oauth_token=\""); authorization.append(oAuth1aToken.token()); authorization.append("\",oauth_signature_method=\""); authorization.append(oAuth1aToken.signatureMethod()); authorization.append("\",oauth_signature=\""); authorization.append(oAuth1aToken.signature()); authorization.append("\",oauth_timestamp=\""); authorization.append(oAuth1aToken.timestamp()); authorization.append("\",oauth_nonce=\""); authorization.append(oAuth1aToken.nonce()); authorization.append("\",version=\""); authorization.append(oAuth1aToken.version()); authorization.append('"'); for (Entry<String, String> entry : oAuth1aToken.additionals().entrySet()) { authorization.append("\","); authorization.append(entry.getKey()); authorization.append("=\""); authorization.append(entry.getValue()); authorization.append('"'); } request.addHeader(header.toString(), authorization.toString()); return request; }
Example 8
Source File: SdxDatabaseDrServiceTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() { if (Strings.isNullOrEmpty(ThreadBasedUserCrnProvider.getUserCrn())) { ThreadBasedUserCrnProvider.setUserCrn(USER_CRN); } flowIdentifier = new FlowIdentifier(FlowType.FLOW, POLLABLE_ID); }
Example 9
Source File: ApiV2ControllerStateTransitionTest.java From we-cmdb with Apache License 2.0 | 4 votes |
private void updateCiData(int ciTypeId, String guid) throws Exception { // get existing description com.webank.cmdb.dto.QueryRequest request; String existingDesc = getFieldValue(ciTypeId, guid, "description", false); Map<?, ?> jsonMap = ImmutableMap.builder() .put("guid", guid) .put("description", "update desc new") .build(); String updateJson = JsonUtil.toJson(ImmutableList.of(jsonMap)); MvcResult updateResult = mvc.perform(post("/api/v2/ci/{ciTypeId}/update", ciTypeId).contentType(MediaType.APPLICATION_JSON) .content(updateJson)) .andExpect(jsonPath("$.statusCode", is("OK"))) .andExpect(jsonPath("$.data", hasSize(equalTo(1)))) .andReturn(); String updatedRet = updateResult.getResponse() .getContentAsString(); JsonNode updateResultDataNode = new ObjectMapper().readTree(updatedRet) .get("data"); if (updateResultDataNode.isArray()) { assertThat(updateResultDataNode.get(0) .get("description") .asText(), equalTo("update desc new")); } String parentGuid = JsonUtil.asNodeByPath(updatedRet, "/data/0/p_guid") .asText(); if (!Strings.isNullOrEmpty(parentGuid)) { // compare the description from parent ci with existing description request = new com.webank.cmdb.dto.QueryRequest(); request.getDialect() .setShowCiHistory(true); request.setFilters(Lists.newArrayList(new Filter("guid", FilterOperator.Equal.getCode(), parentGuid))); MvcResult parentResult = mvc.perform(post("/api/v2/ci/{ciTypeId}/retrieve", ciTypeId).contentType(MediaType.APPLICATION_JSON) .content(JsonUtil.toJson(request))) .andReturn(); String parentRetContent = parentResult.getResponse() .getContentAsString(); String parentDesc = JsonUtil.asNodeByPath(parentRetContent, "/data/contents/0/data/description") .asText(); assertThat(parentDesc, equalTo(existingDesc)); } }