本文整理汇总了Java中org.fest.assertions.Assertions类的典型用法代码示例。如果您正苦于以下问题:Java Assertions类的具体用法?Java Assertions怎么用?Java Assertions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Assertions类属于org.fest.assertions包,在下文中一共展示了Assertions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asMap
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void asMap() throws Exception {
ServiceMetadataProperties serviceMetadataProperties = new ServiceMetadataProperties();
serviceMetadataProperties.setDisplayName("aDisplayName");
serviceMetadataProperties.setLongDescription("a long description");
serviceMetadataProperties.setProviderDisplayName("a provider");
serviceMetadataProperties.setDocumentationUrl("http://localhost/doc");
serviceMetadataProperties.setImageUrl("http://localhost/image.png");
serviceMetadataProperties.setSupportUrl("http://localhost/support");
Assertions.assertThat(serviceMetadataProperties.asMap()).as("get service metatada content as map").hasSize(6).includes(
entry("displayName", "aDisplayName"),
entry("longDescription", "a long description"),
entry("providerDisplayName", "a provider"),
entry("documentationUrl", "http://localhost/doc"),
entry("imageUrl", "http://localhost/image.png"),
entry("supportUrl", "http://localhost/support"));
}
示例2: enable_acut_qcut_scut_ccut
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void enable_acut_qcut_scut_ccut() throws ParseException {
// Given
String[] args = {
"-acut", "0.1", "-qcut", "0.2", "-scut", "0.3", "-ccut", "23",
"-simdoc", "."
};
// When
ClusteringParameters options = (new CommandLineOptions(args)).simClusteringOptions().clusteringParameters;
// Then
Assertions.assertThat(options.acut()).isTrue();
Assertions.assertThat(options.qcut()).isTrue();
Assertions.assertThat(options.scut()).isTrue();
Assertions.assertThat(options.ccut()).isTrue();
Assertions.assertThat(options.wcut).isFalse();
Assertions.assertThat(options.knn()).isFalse();
Assertions.assertThat(options.acutSdFactor).isEqualTo(0.1f);
Assertions.assertThat(options.qcutSdFactor).isEqualTo(0.2f);
Assertions.assertThat(options.scutSdFactor).isEqualTo(0.3f);
Assertions.assertThat(options.ccutPercentile).isEqualTo(23);
}
示例3: remote_build_animals_dna_clustering
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
@Ignore // a running clustering-server on port 6969 is mandatory for this test
public void remote_build_animals_dna_clustering() throws IOException {
// Given
ClusteringRequest req = ClusteringRequest.builder()
.inputDirectory(inputDirectory())
.outputDirectory(OUTPUT_DIRECTORY.getAbsolutePath())
.debug()
.build();
RemoteClustering remoteClustering = new RemoteClustering();
// When
ClusteringRequestResult result = remoteClustering.request("http://localhost:6969", req);
// Then
Assertions.assertThat(result).isEqualTo(expectedClusteringResult());
}
示例4: dispatch_requests_with_all_available_microservices
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void dispatch_requests_with_all_available_microservices() {
// Given
TestResponseCollector responseCollector = new TestResponseCollector(REQUESTS_COUNT);
RequestsProvider requestsProvider = buildRequestProvider();
AvailableRemoteServices availableRemoteServices = buildAvailableRemoteServices();
RequestsExecutor requestsExecutor = new RequestsExecutor(requestsProvider, responseCollector, availableRemoteServices);
// When
requestsExecutor.exec();
// Then
IntStream.range(1, REQUESTS_COUNT).forEach(requestId ->
Assertions.assertThat(responseCollector.get(requestId)).isEqualTo(requestId)
);
}
示例5: remote_computation_on_distinct_elements_arrays
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
@Ignore // a running simdoc-server is mandatory for this test
public void remote_computation_on_distinct_elements_arrays() throws IOException {
// Given
ExportModel referenceModel = readReferenceForDistinctArray();
BytesData[] elements1 = testAnimalsElements.elements();
BytesData[] elements2 = testAnimalsElements.elements();
MatrixDistancesSegments matrixDistancesSegments = new MatrixDistancesSegments(elements1, elements2);
matrixDistancesSegments = matrixDistancesSegments.buildSegments();
RemoteDistancesSegments remoteDistancesSegments =
new RemoteDistancesSegments(matrixDistancesSegments);
// When
List<MatrixDistancesSegment> segments = remoteDistancesSegments.compute();
// Then
segments.stream().forEach(segment -> doAssertion(segment, referenceModel));
ExportModel exportModel = new ExportModel(elements1, elements2, segments);
Assertions.assertThat(exportModel).isEqualTo(referenceModel);
}
示例6: build_distances_matrix_segments_from_elements1_and_elements2
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void build_distances_matrix_segments_from_elements1_and_elements2() {
// Given
BytesData[] bytesData1 = TestElements.elements1();
BytesData[] bytesData2 = TestElements.elements2();
MatrixDistancesSegments matrixDistancesSegments = new MatrixDistancesSegments(bytesData1, bytesData2);
// When
MatrixDistancesSegments result = matrixDistancesSegments.buildSegments();
// Then
Assertions.assertThat(result.segments).hasSize(2);
MatrixDistancesSegment segment1 = result.segments.get(0);
MatrixDistancesSegment segment2 = result.segments.get(1);
Assertions.assertThat(segment1.element.id).isEqualTo("1");
Assertions.assertThat(segment1.elements[0].id).isEqualTo("4");
Assertions.assertThat(segment1.elements[1].id).isEqualTo("1");
Assertions.assertThat(segment1.elements[2].id).isEqualTo("5");
Assertions.assertThat(segment2.element.id).isEqualTo("2");
Assertions.assertThat(segment2.elements[0].id).isEqualTo("4");
Assertions.assertThat(segment2.elements[1].id).isEqualTo("1");
Assertions.assertThat(segment2.elements[2].id).isEqualTo("5");
}
示例7: build_half_matrix_segments_if_elements1_equals_elements2
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void build_half_matrix_segments_if_elements1_equals_elements2() {
// Given
BytesData[] bytesData1 = TestElements.elements2();
BytesData[] bytesData2 = bytesData1;
MatrixDistancesSegments matrixDistancesSegments = new MatrixDistancesSegments(bytesData1, bytesData2);
// When
MatrixDistancesSegments result = matrixDistancesSegments.buildSegments();
// Then
Assertions.assertThat(result.segments).hasSize(3);
MatrixDistancesSegment segment1 = result.segments.get(0);
MatrixDistancesSegment segment2 = result.segments.get(1);
Assertions.assertThat(segment1.element.id).isEqualTo("4");
Assertions.assertThat(segment1.elements).hasSize(2);
Assertions.assertThat(segment1.elements[0].id).isEqualTo("1");
Assertions.assertThat(segment1.elements[1].id).isEqualTo("5");
Assertions.assertThat(segment2.element.id).isEqualTo("1");
Assertions.assertThat(segment2.elements).hasSize(1);
Assertions.assertThat(segment2.elements[0].id).isEqualTo("5");
}
示例8: create_files_id_directory
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void create_files_id_directory() throws IOException {
// Given
buildSourceDir(SRC_DIR, TEST_FILES);
InputFilesConverter inputFilesConverter = InputFilesConverter.builder()
.sourceDirectory(SRC_DIR)
.destinationDirectory(DEST_DIR)
.fileConverter(new SymbolicLinkConverter())
.build();
List<File> nonHiddenSourceFiles = nonHiddenSourceFiles(TEST_FILES);
// When
inputFilesConverter.createSafeWorkingDirectory();
// Then
for (int index = 0; index < nonHiddenSourceFiles.size(); index++) {
File srcFile = nonHiddenSourceFiles.get(index);
File destFile = new File(DEST_DIR.getAbsolutePath() + "/" + index);
Assertions.assertThat(FileUtils.readFileToString(destFile)).isEqualTo(FileUtils.readFileToString(srcFile));
}
}
示例9: create_files_id_mapping
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void create_files_id_mapping() throws IOException {
// Given
buildSourceDir(SRC_DIR, TEST_FILES);
InputFilesConverter inputFilesConverter = InputFilesConverter.builder()
.sourceDirectory(SRC_DIR)
.destinationDirectory(DEST_DIR)
.fileConverter(new SymbolicLinkConverter())
.build();
List<File> nonHiddenSourceFiles = nonHiddenSourceFiles(TEST_FILES);
// When
FilesMap map = inputFilesConverter.createSafeWorkingDirectory();
// Then
map.keySet().forEach(index -> {
File srcFile = nonHiddenSourceFiles.get(index);
Assertions.assertThat(map.get(index)).isEqualTo(srcFile.getAbsolutePath());
});
}
示例10: prep_bytes_data
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void prep_bytes_data() throws IOException {
// Given
File inputDirectory = new File(getClass().getResource("/prep-data-test-input-dir").getFile());
PrepData prepData = PrepData.builder()
.inputDirectory(inputDirectory)
.preppedBytesDataOutputFile(PREPPED_DATA_JSON)
.build();
JsonGenericHandler jsonGenericHandler = new JsonGenericHandler();
// When
prepData.prep();
PreppedBytesData preppedBytesData =
(PreppedBytesData) jsonGenericHandler.getObjectFromJsonFile(PreppedBytesData.class, PREPPED_DATA_JSON);
// Then
Assertions.assertThat(preppedBytesData.bytesData.length).isEqualTo(2);
Assertions.assertThat(preppedBytesData.bytesData[0].id).isEqualTo("image.png");
Assertions.assertThat(preppedBytesData.bytesData[1].id).isEqualTo("subdir/opossum");
Assertions.assertThat(preppedBytesData.bytesData[0].filepath).isEqualTo(new File(inputDirectory.getAbsolutePath() + "/image.png").getAbsolutePath());
Assertions.assertThat(preppedBytesData.bytesData[1].filepath).isEqualTo(new File(inputDirectory.getAbsolutePath() + "/subdir/opossum").getAbsolutePath());
Assertions.assertThat(preppedBytesData.bytesData[0].bytes).isNull();
Assertions.assertThat(preppedBytesData.bytesData[1].bytes).isNull();
}
示例11: prep_bytes_data_with_bytes
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void prep_bytes_data_with_bytes() throws IOException {
// Given
File inputDirectory = new File(getClass().getResource("/prep-data-test-input-dir").getFile());
PrepData prepData = PrepData.builder()
.inputDirectory(inputDirectory)
.preppedBytesDataOutputFile(PREPPED_DATA_JSON)
.withBytes(true)
.build();
JsonGenericHandler jsonGenericHandler = new JsonGenericHandler();
// When
prepData.prep();
PreppedBytesData preppedBytesData =
(PreppedBytesData) jsonGenericHandler.getObjectFromJsonFile(PreppedBytesData.class, PREPPED_DATA_JSON);
// Then
Assertions.assertThat(preppedBytesData.bytesData.length).isEqualTo(2);
Assertions.assertThat(preppedBytesData.bytesData[0].id).isEqualTo("image.png");
Assertions.assertThat(preppedBytesData.bytesData[1].id).isEqualTo("subdir/opossum");
Assertions.assertThat(preppedBytesData.bytesData[0].filepath).isEqualTo(new File(inputDirectory.getAbsolutePath() + "/image.png").getAbsolutePath());
Assertions.assertThat(preppedBytesData.bytesData[1].filepath).isEqualTo(new File(inputDirectory.getAbsolutePath() + "/subdir/opossum").getAbsolutePath());
Assertions.assertThat(preppedBytesData.bytesData[0].bytes).isNotNull();
Assertions.assertThat(preppedBytesData.bytesData[1].bytes).isNotNull();
}
示例12: build_parameters
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void build_parameters() {
// Given
// When
ClusteringParameters parameters = ClusteringParameters.builder()
.acut()
.qcut()
.scut()
.ccut()
.wcut()
.sloop()
.build();
// Then
Assertions.assertThat(parameters.qcut()).isTrue();
Assertions.assertThat(parameters.acut()).isTrue();
Assertions.assertThat(parameters.scut()).isTrue();
Assertions.assertThat(parameters.scutSdFactor).isEqualTo(ClusteringParameters.SCUT_DEFAULT_SD_FACTOR);
Assertions.assertThat(parameters.ccut()).isTrue();
Assertions.assertThat(parameters.wcut).isTrue();
Assertions.assertThat(parameters.knn()).isFalse();
Assertions.assertThat(parameters.sloop).isTrue();
}
示例13: compute_triangles_areas_directly_with_triangle_vertices_with_knn_criteria
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void compute_triangles_areas_directly_with_triangle_vertices_with_knn_criteria() {
// given
ClusteringItem[] clusteringItems = getClusteringItemsWithVertices(1);
ClusteringGraphBuilder clusteringGraphBuilder = new ClusteringGraphBuilder();
ClusteringParameters parameters = ClusteringParameters.builder().acut().qcut().build();
// do
ClusteringGraph clusteringGraph = clusteringGraphBuilder.buildGraphAndUpdateClusterIdAndCenter(clusteringItems, parameters);
// then
List<GraphItem> graphItems = clusteringGraph.getItems();
Assertions.assertThat(graphItems.get(0).iskNNSingleton()).isTrue();
float[] expectedAreas = getExpectedAreas();
float[] expectedQ = getExpectedQ();
for (int i = 1; i < clusteringItems.length; i++) {
GraphItem graphItem = graphItems.get(i);
Assertions.assertThat(graphItem.iskNNSingleton()).isFalse();
Assert.assertEquals(expectedAreas[i], graphItem.getArea(), 0.01f);
Assert.assertEquals(expectedQ[i], graphItem.getQ(), 0.01f);
}
}
开发者ID:Orange-OpenSource,项目名称:documentare-simdoc,代码行数:24,代码来源:FixmeClusteringGraphBuilderQAreaKnnTest.java
示例14: check_items_are_in_correct_cluster
import org.fest.assertions.Assertions; //导入依赖的package包/类
@TestWith({"false, 1.96", "true, 3"})
public void check_items_are_in_correct_cluster(boolean sloop, float scut) {
// given
ClusteringItem[] clusteringItems = Item.buildClusteringItems(this, 6);
ClusteringGraphBuilder clusteringGraphBuilder = new ClusteringGraphBuilder();
ClusteringParameters parameters = sloop ?
ClusteringParameters.builder().scut(scut).sloop().build() :
ClusteringParameters.builder().scut(scut).build();
// do
clusteringGraphBuilder.buildGraphAndUpdateClusterIdAndCenter(clusteringItems, parameters);
// then
Assertions.assertThat(clusteringItems[0].getClusterId()).isEqualTo(1);
Assertions.assertThat(clusteringItems[1].getClusterId()).isEqualTo(1);
Assertions.assertThat(clusteringItems[2].getClusterId()).isEqualTo(1);
Assertions.assertThat(clusteringItems[3].getClusterId()).isEqualTo(2);
Assertions.assertThat(clusteringItems[4].getClusterId()).isEqualTo(3);
Assertions.assertThat(clusteringItems[5].getClusterId()).isEqualTo(3);
}
示例15: compute_distance_on_strings
import org.fest.assertions.Assertions; //导入依赖的package包/类
@Test
public void compute_distance_on_strings() {
// given
Ncd ncd = new Ncd();
byte[][] inputs = buildInputs();
// do
float ncdResult01 = ncd.computeNcd(inputs[0], inputs[1]);
float ncdResult23 = ncd.computeNcd(inputs[2], inputs[3]);
float ncdResult45 = ncd.computeNcd(inputs[4], inputs[5]);
// then
Assertions.assertThat(ncdResult01).isEqualTo(0f);
Assertions.assertThat(ncdResult23).isEqualTo(0.5714286f);
Assertions.assertThat(ncdResult45).isEqualTo(0.45454547f);
Assertions.assertThat(ncd.compressedLengthCache.getIfPresent(Arrays.hashCode(inputs[0]))).isEqualTo(210);
Assertions.assertThat(ncd.compressedLengthCache.getIfPresent(Arrays.hashCode(inputs[1]))).isEqualTo(210);
Assertions.assertThat(ncd.compressedLengthCache.getIfPresent(Arrays.hashCode(inputs[2]))).isEqualTo(210);
Assertions.assertThat(ncd.compressedLengthCache.getIfPresent(Arrays.hashCode(inputs[3]))).isEqualTo(100);
}