List of usage examples for org.apache.commons.lang3 StringUtils substringAfterLast
public static String substringAfterLast(final String str, final String separator)
Gets the substring after the last occurrence of a separator.
From source file:cn.aozhi.songify.functional.rest.TaskRestFT.java
/** * //./*from w ww.ja v a 2 s . c o m*/ */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create Task task = TaskData.randomTask(); URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task); System.out.println(createdTaskUri.toString()); Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/"); task.setId(new Long(id)); task.setTitle(TaskData.randomTitle()); restTemplate.put(createdTaskUri, task); Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(createdTaskUri); try { restTemplate.getForObject(createdTaskUri, Task.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:cn.dsgrp.field.stock.functional.rest.TaskRestFT.java
/** * //./*from ww w.j a v a 2 s .c o m*/ */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create Task task = TaskData.randomTask(); URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task); System.out.println(createdTaskUri.toString()); Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/"); task.setId(BigInteger.valueOf(Long.parseLong(id))); task.setTitle(TaskData.randomTitle()); restTemplate.put(createdTaskUri, task); Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(createdTaskUri); try { restTemplate.getForObject(createdTaskUri, Task.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:com.quatico.base.aem.test.api.values.ResourceType.java
private boolean isTypeEqualTo(String resourceType) { String pageName = StringUtils.substringAfterLast(getName(), "/"); return StringUtils.isNotEmpty(pageName) && resourceType != null ? resourceType.endsWith(pageName) : this.equals(resourceType); }
From source file:com.asiainfo.tfsPlatform.web.functional.rest.TaskRestFT.java
/** * //.//from w w w. j a v a 2 s . c o m */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create TaskDto task = TaskData.randomTask(); URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task); System.out.println(createdTaskUri.toString()); TaskDto createdTask = restTemplate.getForObject(createdTaskUri, TaskDto.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/"); task.setId(new Long(id)); task.setTitle(TaskData.randomTitle()); restTemplate.put(createdTaskUri, task); TaskDto updatedTask = restTemplate.getForObject(createdTaskUri, TaskDto.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(createdTaskUri); try { restTemplate.getForObject(createdTaskUri, TaskDto.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:io.wcm.handler.mediasource.dam.impl.RenditionMetadata.java
/** * @param rendition DAM rendition//from www. ja v a 2s.c om */ public RenditionMetadata(Rendition rendition) { this.rendition = rendition; // check if rendition is original image boolean isOriginal = isOriginalRendition(rendition); Asset asset = rendition.getAsset(); // get filename and extension String renditionName = rendition.getName(); if (isOriginal) { renditionName = asset.getName(); } this.fileName = renditionName; this.fileExtension = StringUtils.substringAfterLast(renditionName, "."); // get image width/height int imageWidth = 0; int imageHeight = 0; if (isOriginal) { // get width/height from metadata for original renditions try { imageWidth = Integer.parseInt( StringUtils.defaultString(asset.getMetadataValue(DamConstants.TIFF_IMAGEWIDTH), "0")); } catch (NumberFormatException ex) { // ignore } if (imageWidth == 0) { try { imageWidth = Integer.parseInt(StringUtils .defaultString(asset.getMetadataValue(DamConstants.EXIF_PIXELXDIMENSION), "0")); } catch (NumberFormatException ex) { // ignore } } try { imageHeight = Integer.parseInt( StringUtils.defaultString(asset.getMetadataValue(DamConstants.TIFF_IMAGELENGTH), "0")); } catch (NumberFormatException ex) { // ignore } if (imageHeight == 0) { try { imageHeight = Integer.parseInt(StringUtils .defaultString(asset.getMetadataValue(DamConstants.EXIF_PIXELYDIMENSION), "0")); } catch (NumberFormatException ex) { // ignore } } } else if (FileExtension.isImage(this.fileExtension)) { // otherwise get from rendition metadata written by {@link DamRenditionMetadataService} String metadataPath = JcrConstants.JCR_CONTENT + "/" + DamRenditionMetadataService.NN_RENDITIONS_METADATA + "/" + rendition.getName(); Resource metadataResource = asset.adaptTo(Resource.class).getChild(metadataPath); if (metadataResource != null) { ValueMap props = metadataResource.getValueMap(); imageWidth = props.get(DamRenditionMetadataService.PN_IMAGE_WIDTH, 0); imageHeight = props.get(DamRenditionMetadataService.PN_IMAGE_HEIGHT, 0); } } this.width = imageWidth; this.height = imageHeight; }
From source file:com.bill99.yn.webmgmt.functional.rest.TaskRestFT.java
/** * //.// w w w . j a va 2 s . c o m */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create Task task = TaskData.randomTask(); URI taskUri = restTemplate.postForLocation(resoureUrl, task); System.out.println(taskUri.toString()); Task createdTask = restTemplate.getForObject(taskUri, Task.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(taskUri.toString(), "/"); task.setId(new Long(id)); task.setTitle(TaskData.randomTitle()); restTemplate.put(taskUri, task); Task updatedTask = restTemplate.getForObject(taskUri, Task.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(taskUri); try { restTemplate.getForObject(taskUri, Task.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:$.TaskRestFT.java
/** * //.//from w ww . ja v a 2s .c o m */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create Task task = TaskData.randomTask(); URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task); System.out.println(createdTaskUri.toString()); Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/"); task.setId(new Long(id)); task.setTitle(TaskData.randomTitle()); restTemplate.put(createdTaskUri, task); Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(createdTaskUri); try { restTemplate.getForObject(createdTaskUri, Task.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:com.zht.common.codegen.excute.impl.JSPGeneratorImplNew.java
@Override public void genjsp_add(String entityFullClassName, String controllerNameSpace, GenEntity genEntity, List<GenEntityProperty> genEntityPropertyList) { JSPModelNew jSPModel = new JSPModelNew(); //??//from w w w. ja v a 2s. c o m String entitySimpleClassName = StringUtils.substringAfterLast(entityFullClassName, "."); // String str = StringUtils.substringBeforeLast(entityFullClassName, "."); str = StringUtils.substringBeforeLast(str, "."); String firstLower = ZStrUtil.toLowerCaseFirst(entitySimpleClassName); jSPModel.setControllerNameSpace(controllerNameSpace); jSPModel.setEntityFullClassName(entityFullClassName); jSPModel.setEntitySimpleClassName(entitySimpleClassName); jSPModel.setGenEntity(genEntity); jSPModel.setGenEntityPropertyList(genEntityPropertyList); Map<String, Object> data = new HashMap<String, Object>(); data.put("model", jSPModel); String filePath = new String(GenConstant.project_path + "WebRoot/WEB-INF/jsp/" + controllerNameSpace + "/" + firstLower + "Add.jsp"); super.generate(GenConstant.jsp_add_template_dir, data, filePath); }
From source file:mobi.jenkinsci.server.Config.java
public String getMimeType(final String resourceFileName) { return MIME_TYPES.get(StringUtils.substringAfterLast(resourceFileName, ".")); }
From source file:alliance.docs.DocumentationTest.java
@Test public void testBrokenAnchorsPresent() throws IOException, URISyntaxException { List<Path> docs = Files.list(getPath()).filter(f -> f.toString().endsWith(HTML_DIRECTORY)) .collect(Collectors.toList()); Set<String> links = new HashSet<>(); Set<String> anchors = new HashSet<>(); for (Path path : docs) { Document doc = Jsoup.parse(path.toFile(), "UTF-8", EMPTY_STRING); String thisDoc = StringUtils.substringAfterLast(path.toString(), File.separator); Elements elements = doc.body().getAllElements(); for (Element element : elements) { if (!element.toString().contains(":") && StringUtils.substringBetween(element.toString(), HREF_ANCHOR, CLOSE) != null) { links.add(thisDoc + "#" + StringUtils.substringBetween(element.toString(), HREF_ANCHOR, CLOSE)); }/*from ww w . j av a2s.c o m*/ anchors.add(thisDoc + "#" + StringUtils.substringBetween(element.toString(), ID, CLOSE)); } } links.removeAll(anchors); assertThat("Anchors missing section reference: " + links.toString(), links.isEmpty()); }