本文整理汇总了Java中org.assertj.core.data.Offset类的典型用法代码示例。如果您正苦于以下问题:Java Offset类的具体用法?Java Offset怎么用?Java Offset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Offset类属于org.assertj.core.data包,在下文中一共展示了Offset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: percentilesChangeWithMoreRecentSamples
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
void percentilesChangeWithMoreRecentSamples() {
TimeWindowLatencyHistogram histogram = new TimeWindowLatencyHistogram(new MockClock(), HistogramConfig.DEFAULT, noPause);
for(int i = 1; i <= 10; i++) {
histogram.recordLong((long) millisToUnit(i, TimeUnit.NANOSECONDS));
}
// baseline median
assertThat(nanosToUnit(histogram.percentile(0.50), TimeUnit.MILLISECONDS)).isEqualTo(5, Offset.offset(0.1));
for(int i = 11; i <= 20; i++) {
histogram.recordLong((long) millisToUnit(i, TimeUnit.NANOSECONDS));
}
// median should have moved after seeing 10 more samples
assertThat(nanosToUnit(histogram.percentile(0.50), TimeUnit.MILLISECONDS)).isEqualTo(10, Offset.offset(0.1));
}
示例2: parse_ShouldParseLine_WithoutDuration
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test(timeout = 1000)
public void parse_ShouldParseLine_WithoutDuration() {
String input = "Encoding: task 1 of 1, 5.11 %";
subject.onProgressParsed()
.ofType(HandbrakeOutput.class)
.subscribe(p -> {
assertThat(p.getPercentage()).isCloseTo(5.11d, Offset.offset(0.001d));
assertThat(p.getAverageFps()).isZero();
assertThat(p.getEta()).isEqualTo("00:00:00");
assertThat(p.getFps()).isZero();
completeOne();
});
subject.parse(input);
waitForCompletion();
}
示例3: parse_ShouldParseLine_WithDuration
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test(timeout = 1000)
public void parse_ShouldParseLine_WithDuration() {
String input = "Encoding: task 1 of 1, 5.11 % (67.61 fps, avg 67.59 fps, ETA 00h20m43s))";
subject.onProgressParsed()
.ofType(HandbrakeOutput.class)
.subscribe(p -> {
assertThat(p.getPercentage()).isCloseTo(5.11d, Offset.offset(0.001d));
assertThat(p.getAverageFps()).isCloseTo(67.59d, Offset.offset(0.001d));
assertThat(p.getEta()).isEqualTo("00:20:43");
assertThat(p.getFps()).isCloseTo(67.61d, Offset.offset(0.001d));
completeOne();
});
subject.parse(input);
waitForCompletion();
}
示例4: testDragAndDrop
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void testDragAndDrop() throws Exception {
pane.zoomTo(2, pane.targetPointAtViewportCentre());
Transform expected = target.captureTransform();
FxRobot robot = new FxRobot();
robot.moveTo(pane)
.drag(MouseButton.PRIMARY).dropBy(100, 100);
Transform actual = target.captureTransform();
assertThat(actual).isEqualToComparingOnlyGivenFields(expected,
"xx", "xy", "xz",
"yx", "yy", "yz",
"zx", "zy", "zz",
/* "xt", "yt", */ "zt"); // x y will have delta
assertThat(actual.getTx()).isCloseTo(expected.getTx() + 100, Offset.offset(10d));
assertThat(actual.getTy()).isCloseTo(expected.getTy() + 100, Offset.offset(10d));
}
示例5: test_magnitude
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void test_magnitude() throws Exception {
// Given:
int x = 5;
int y = 4;
int z = 3;
double expected = Math.sqrt(x * x + y * y + z * z);
// When:
mc().executeCommand("/lua v=Vec3.from(%s,%s,%s); print(v:magnitude())", x, y, z);
// Then:
ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
double actValue = Double.parseDouble(act.getMessage());
assertThat(actValue).isEqualTo(expected, Offset.offset(0.01));
}
示例6: verifySpanDeepEquals
import org.assertj.core.data.Offset; //导入依赖的package包/类
private void verifySpanDeepEquals(Span span1, Span span2, boolean allowStartTimeNanosFudgeFactor) {
assertThat(span1.getSpanStartTimeEpochMicros()).isEqualTo(span2.getSpanStartTimeEpochMicros());
if (allowStartTimeNanosFudgeFactor)
assertThat(span1.getSpanStartTimeNanos()).isCloseTo(span2.getSpanStartTimeNanos(), Offset.offset(TimeUnit.MILLISECONDS.toNanos(1)));
else
assertThat(span1.getSpanStartTimeNanos()).isEqualTo(span2.getSpanStartTimeNanos());
assertThat(span1.isCompleted()).isEqualTo(span2.isCompleted());
assertThat(span1.getTraceId()).isEqualTo(span2.getTraceId());
assertThat(span1.getSpanId()).isEqualTo(span2.getSpanId());
assertThat(span1.getParentSpanId()).isEqualTo(span2.getParentSpanId());
assertThat(span1.getSpanName()).isEqualTo(span2.getSpanName());
assertThat(span1.isSampleable()).isEqualTo(span2.isSampleable());
assertThat(span1.getUserId()).isEqualTo(span2.getUserId());
assertThat(span1.getDurationNanos()).isEqualTo(span2.getDurationNanos());
assertThat(span1.getSpanPurpose()).isEqualTo(span2.getSpanPurpose());
}
示例7: shouldGetThresholdValue
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test(dataProvider = "thresholdValueCases")
public void shouldGetThresholdValue(@NotNull final BigDecimal prevValue, @NotNull final ThresholdValue threshold, @Nullable final BigDecimal expectedThresholdValue)
{
// Given
final MetricComparer instance = createInstance();
// When
final BigDecimal actualThresholdValue = instance.tryGetThresholdValue(prevValue, threshold);
// Then
if(expectedThresholdValue == null) {
then(actualThresholdValue).isNull();
}
else {
then(actualThresholdValue).isCloseTo(expectedThresholdValue, Offset.offset(new BigDecimal(.0001)));
}
}
示例8: shouldAggregate
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test(dataProvider = "aggregateCases")
public void shouldAggregate(@NotNull final Iterable<BigDecimal> values, final boolean expectedIsCompleted, @Nullable final BigDecimal expectedAggregatedValue)
{
// Given
final ValueAggregator instance = createInstance();
// When
for(BigDecimal value: values) {
instance.aggregate(value);
}
// Then
then(instance.isCompleted()).isEqualTo(expectedIsCompleted);
if(expectedAggregatedValue == null) {
then(instance.tryGetAggregatedValue()).isNull();
}
else {
then(instance.tryGetAggregatedValue()).isCloseTo(expectedAggregatedValue, Offset.offset(new BigDecimal(.0001)));
}
}
示例9: testLerp
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void testLerp() {
Offset<Double> offsetD = Offset.offset(1e-11);
Offset<Float> offsetF = Offset.offset(1e-7F);
assertThat(MathUtil.lerp(1D, 2D, 0)).isCloseTo(1, offsetD);
assertThat(MathUtil.lerp(1D, 2D, .5)).isCloseTo(1.5, offsetD);
assertThat(MathUtil.lerp(1D, 2D, 1)).isCloseTo(2, offsetD);
assertThat(MathUtil.lerp(1F, 2F, 0F)).isCloseTo(1F, offsetF);
assertThat(MathUtil.lerp(1F, 2F, .5F)).isCloseTo(1.5F, offsetF);
assertThat(MathUtil.lerp(1F, 2F, 1F)).isCloseTo(2F, offsetF);
assertThat(MathUtil.lerp(Vector3D.ZERO, Vector3DUtil.ONE, 0)).isAlmostEqualTo(Vector3D.ZERO);
assertThat(MathUtil.lerp(Vector3D.ZERO, Vector3DUtil.ONE, .5F)).isAlmostEqualTo(Vector3DUtil.ONE.scalarMultiply(0.5));
assertThat(MathUtil.lerp(Vector3D.ZERO, Vector3DUtil.ONE, 1)).isAlmostEqualTo(Vector3DUtil.ONE);
}
示例10: should_parse_array_of_hits
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void should_parse_array_of_hits() throws IOException {
String json = readFromClasspath("json/entity/hit_array.json");
String source = readFromClasspath("json/entity/source.json");
XContentParser parser = XContentHelper.createParser(json.getBytes(), 0, json.length());
parser.nextToken();
List<Hit> hits = Hit.parseHitArray(parser);
assertThat(hits).hasSize(2);
Hit hit = hits.get(0);
assertThat(hit.getId()).isEqualTo("1");
assertThat(hit.getType()).isEqualTo("tweet");
assertThat(hit.getIndex()).isEqualTo("twitter");
assertThat(hit.getScore()).isEqualTo(1.7f, Offset.offset(0.01f));
assertThatJson(new String(hit.getSource())).isEqualTo(source);
Hit hit2 = hits.get(1);
assertThat(hit2.getId()).isEqualTo("2");
assertThat(hit2.getType()).isEqualTo("tweet");
assertThat(hit2.getIndex()).isEqualTo("twitter");
}
示例11: should_parse_hit_with_highlights
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void should_parse_hit_with_highlights() throws Exception {
String json = readFromClasspath("json/entity/hit_with_highlight.json");
XContentParser parser = XContentHelper.createParser(json.getBytes(), 0, json.length());
parser.nextToken();
Hit hit = new Hit().parse(parser);
assertThat(hit.getId()).isEqualTo("2");
assertThat(hit.getType()).isEqualTo("tweet");
assertThat(hit.getIndex()).isEqualTo("twitter2");
assertThat(hit.getScore()).isEqualTo(1, Offset.offset(0.01f));
assertThat(hit.getSource().length).isGreaterThan(1);
assertThat(hit.getHighlights()).hasSize(1);
assertThat(hit.getHighlights().get("message").getValues()).contains("the <em>message</em>");
}
示例12: should_parse_hit_with_fields
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void should_parse_hit_with_fields() throws Exception {
String json = readFromClasspath("json/entity/hit_with_fields.json");
XContentParser parser = XContentHelper.createParser(json.getBytes(), 0, json.length());
parser.nextToken();
Hit hit = new Hit().parse(parser);
assertThat(hit.getId()).isEqualTo("1");
assertThat(hit.getType()).isEqualTo("tweet");
assertThat(hit.getIndex()).isEqualTo("twitter2");
assertThat(hit.getScore()).isEqualTo(1, Offset.offset(0.01f));
assertThat(hit.getSource()).isNull();
assertThat(hit.getFields()).hasSize(2);
assertThat(hit.getFields()).containsKey("message");
assertThat(hit.getFields()).containsKey("the_int");
assertThat(hit.getFields().get("message").getValues()).containsOnly("the message");
assertThat(hit.getFields().get("the_int").getValues()).containsOnly("2");
}
示例13: should_parse_hit_with_explanation
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void should_parse_hit_with_explanation() throws Exception {
String json = readFromClasspath("json/entity/hit_with_explanation.json");
XContentParser parser = XContentHelper.createParser(json.getBytes(), 0, json.length());
parser.nextToken();
Hit hit = new Hit().parse(parser);
assertThat(hit.getId()).isEqualTo("1");
assertThat(hit.getType()).isEqualTo("tweet");
assertThat(hit.getIndex()).isEqualTo("twitter2");
assertThat(hit.getScore()).isEqualTo(1, Offset.offset(0.01f));
assertThat(hit.getExplanation()).isNotNull();
assertThat(hit.getExplanation().getValue()).isEqualTo(1);
assertThat(hit.getExplanation().getDescription()).isEqualTo("ConstantScore(*:*), product of:");
assertThat(hit.getExplanation().getDetails()).hasSize(2);
assertThat(hit.getExplanation().getDetails().get(0).getDetails()).isEmpty();
assertThat(hit.getExplanation().getDetails().get(0).getValue()).isEqualTo(1);
assertThat(hit.getExplanation().getDetails().get(0).getDescription()).isEqualTo("boost");
assertThat(hit.getExplanation().getDetails().get(0).getDetails()).isEmpty();
assertThat(hit.getExplanation().getDetails().get(0).getValue()).isEqualTo(1);
assertThat(hit.getExplanation().getDetails().get(1).getDescription()).isEqualTo("queryNorm");
}
示例14: testAddComponentToParentWithExpandRatio
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void testAddComponentToParentWithExpandRatio() throws Exception {
Button btn1 = new Button();
Button btn2 = new Button();
HorizontalSplitPanel panel = new HorizontalSplitPanel();
VisualTreeNode splitPanelVisualTreeNode = new VisualTreeNodeImpl(panel);
splitPanelVisualTreeNode.setAdditionalParameter("splitPosition", "0.65");
factory.addComponentToParent(splitPanelVisualTreeNode, new VisualTreeNodeImpl(btn1));
factory.addComponentToParent(splitPanelVisualTreeNode, new VisualTreeNodeImpl(btn2));
assertThat(panel.getComponentCount()).isEqualTo(2);
assertThat(panel.getFirstComponent()).isSameAs(btn1);
assertThat(panel.getSecondComponent()).isSameAs(btn2);
assertThat(panel.getSplitPositionUnit()).isEqualTo(Sizeable.Unit.PERCENTAGE);
assertThat(panel.getSplitPosition()).isEqualTo(0.65f * 100.f, Offset.offset(0.01f));
}
示例15: testAddComponentToParent
import org.assertj.core.data.Offset; //导入依赖的package包/类
@Test
public void testAddComponentToParent() throws Exception {
HorizontalLayout layout = new HorizontalLayout();
Button button = new Button();
VisualTreeNodeImpl buttonVisualTreeNode = new VisualTreeNodeImpl(button);
buttonVisualTreeNode.setAdditionalParameter("alignment", "BOTTOM_RIGHT");
buttonVisualTreeNode.setAdditionalParameter("expandRatio", "0.65");
factory.addComponentToParent(new VisualTreeNodeImpl(layout), buttonVisualTreeNode);
assertThat(layout.getComponentCount()).isEqualTo(1);
assertThat(layout.getComponent(0)).isSameAs(button);
assertThat(layout.getComponentAlignment(button)).isEqualTo(Alignment.BOTTOM_RIGHT);
assertThat(layout.getExpandRatio(button)).isEqualTo(0.65f, Offset.offset(0.001f));
}