本文整理匯總了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);
}