automation.library.conversion2jmx.postman2jmx.parser.AbstractParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of library-conversion2jmx Show documentation
Show all versions of library-conversion2jmx Show documentation
The 'conversion2jmx' library to helps creating JMeter JMX files from different sources
The newest version!
package automation.library.conversion2jmx.postman2jmx.parser;
import com.fasterxml.jackson.databind.ObjectMapper;
import automation.library.conversion2jmx.postman2jmx.model.postman.PostmanCollection;
import automation.library.conversion2jmx.postman2jmx.model.postman.PostmanItem;
import automation.library.conversion2jmx.postman2jmx.utils.PostmanCollectionUtils;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
public abstract class AbstractParser implements IParser {
private ObjectMapper objectMapper;
public AbstractParser() {
objectMapper = new ObjectMapper();
}
protected ObjectMapper getMapper() {
return this.objectMapper;
}
protected PostmanCollection readValue(String fileName) throws IOException {
byte[] jsonData = Files.readAllBytes(Paths.get(fileName));
PostmanCollection postmanCollection = getMapper().readValue(jsonData, PostmanCollection.class);
getItems(postmanCollection);
return postmanCollection;
}
protected PostmanCollection readValue(InputStream is) throws IOException {
PostmanCollection postmanCollection = getMapper().readValue(is, PostmanCollection.class);
getItems(postmanCollection);
return postmanCollection;
}
protected void getItems(PostmanCollection postmanCollection) {
List items = PostmanCollectionUtils.getItems(postmanCollection);
Collections.sort(items);
postmanCollection.setItems(items);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy