org.testcontainers.images.builder.traits.StringsTrait Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testcontainers Show documentation
Show all versions of testcontainers Show documentation
Isolated container management for Java code testing
package org.testcontainers.images.builder.traits;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.testcontainers.images.builder.Transferable;
/**
* BuildContextBuilder's trait for String-based manipulations.
*
*/
public interface StringsTrait & BuildContextBuilderTrait> {
default SELF withFileFromString(String path, String content) {
return ((SELF) this).withFileFromTransferable(
path,
new Transferable() {
@Getter
byte[] bytes = content.getBytes();
@Override
public long getSize() {
return bytes.length;
}
@Override
public String getDescription() {
return "String: " + StringUtils.abbreviate(content, 100);
}
}
);
}
}