我有一个带有子节点(节点)的自定义LinkedTree,节点具有邻接关系,即每个节点与上一个节点和下一个节点链接.这个LinkedTree非常重,很大,可能包含数百万个节点.

这是一个代码示例:
package tree;
import java.io.Serializable;
public class LinkedTree<E> implements Serializable {
private int size = 0;
private Node<E> first;
private Node<E> last;
private LinkedTree<E> children;
public LinkedTree() {
children = new LinkedTree<>();
}
public LinkedTree(LinkedTree<E> children) {
this.children = children;
}
public void add(E element) {
final Node<E> l = last;
final Node<E> newNode = new Node<>(l, element, null);
last = newNode;
if (l == null)
first = newNode;
else
l.next = newNode;
size++;
}
public void remove(E element) …Run Code Online (Sandbox Code Playgroud) 我要添加一些形状LineChart.我把LineChart和AnchorPane入StackPane.我AnchorPane通过从图表系列中获取x和y坐标来添加形状.这是一个例子.
LineChartApp.java
package shapes;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class LineChartApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setScene(new Scene(new ChartContent()));
primaryStage.setMaximized(true);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
ChartContent.java
package shapes;
import java.util.ArrayList;
import java.util.List;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane; …Run Code Online (Sandbox Code Playgroud) 假设我们有一个名为SomeClass的java类
public class SomeClass {
private boolean isMethod() {
return false;
}
public void sendRequest(String json, String text) {
int messageId;
if (isMethod()) {
messageId = getMessageId(json);
sendMessage(messageId, text);
} else {
throw new IllegalArgumentException();
}
}
private void sendMessage(int messageId, String text) {
}
private int getMessageId(String text) {
Pattern p = Pattern.compile("messageId=(\\d+)&");
Matcher m = p.matcher(text);
if (m.find()) {
return Integer.valueOf(m.group(1));
}
return 0;
}
}
Run Code Online (Sandbox Code Playgroud)
不要注意方法的名称,它们都是可选的.
sendRequest(String json, String text)方法.isMethod()和getMessageId(json),并验证 …我现在正在ArgoUML中设计UML活动图。我知道,如果我想设计如下条件:
if(condition) {
doTrueAction();
} else {
doFalseAction();
}
Run Code Online (Sandbox Code Playgroud)
可以在UML活动图中完成,如下所示:

但是,如果我们在先前决策的输出中还有另一个条件怎么办?像这样:
if(condition) {
if(condition2) {
condition2TrueAction();
} else {
condition2FalseAction();
}
}else{
conditionFalseAction();
}
Run Code Online (Sandbox Code Playgroud)
如您所见,这里同时输出conditionTrueOutput和condition。在我看来,设计已损坏。
编辑:还是我应该使用fork元素而不是决策(钻石)元素?
我想知道如何正确设计。有什么规定吗?
我尝试-fx-pref-height: 10px;在方向为水平时设置厚度,并-fx-pref-width: 10px;在滚动条方向为垂直时设置厚度.但是不起作用.
.scroll-bar:horizontal .thumb {
-fx-background-color: derive(black, 90%);
-fx-background-insets: 2, 0, 0;
-fx-background-radius: 0em;
-fx-pref-height: 10px;
}
.scroll-bar:vertical .thumb {
-fx-background-color: derive(black, 90%);
-fx-background-insets: 2, 0, 0;
-fx-background-radius: 0em;
-fx-pref-width: 10px;
}
Run Code Online (Sandbox Code Playgroud)
如何通过自定义css实现这一目标?
我需要模拟对 GenericService 的 findById 方法的调用。
我有这个:
public class UserServiceImpl extends GenericServiceImpl<User Integer> implements UserService, Serializable {
....
// This call i want mock
user = findById(user.getId());
.....
// For example this one calls mockeo well. Why is not it a call to the generic service?
book = bookService.findById(id);
Run Code Online (Sandbox Code Playgroud)
问题出在第一个模拟中,因为它是对通用服务的调用。
第二个模拟也很好用
when(bookService.findById(anyInt())).thenReturn(mockedBook);
Run Code Online (Sandbox Code Playgroud) 我有一个具有私有方法的类,并在其正文中调用另一个私有方法.所以我想调用第一个私有方法并模拟第二个私有方法.这是一个例子:
public class ClassWithPrivateMethod {
private int count;
public ClassWithPrivateMethod() {
}
private void countDown() {
while (isDecrementable())
count--;
}
private boolean isDecrementable() {
throw new IllegalArgumentException();
// if (count > 0) return true;
// return false;
}
}
Run Code Online (Sandbox Code Playgroud)
和测试类:
@RunWith(PowerMockRunner.class)
@PrepareForTest(ClassWithPrivateMethodTest.class)
public class ClassWithPrivateMethodTest {
private int count;
private ClassWithPrivateMethod classWithPrivateMethod;
@Before
public void setUp() throws Exception {
count = 3;
classWithPrivateMethod = PowerMockito.spy(new ClassWithPrivateMethod());
}
@Test
public void countDown() throws Exception {
Whitebox.setInternalState(classWithPrivateMethod, "count", count);
PowerMockito.doReturn(true, true, false).when(classWithPrivateMethod, …Run Code Online (Sandbox Code Playgroud) 我有一个带有布尔值的数组。但是像这样的元素序列:首先是true值,然后是false值。例如,
boolean[] booleans = {true, true, true, true, true,
false, false, false, false, false, false};
Run Code Online (Sandbox Code Playgroud)
所以现在我们有一个带有布尔值的排序数组,true如果true值存在,则从值开始。
任务是找到第一个false元素。
我使用二分搜索算法创建了一个带有搜索方法的类。
public class BinarySearch {
public static int search(boolean[] array) {
int low = 0, mid = 0;
int high = array.length - 1;
boolean booleanValue;
while (low <= high) {
mid = (low + high) >>> 1;
booleanValue = array[mid];
if (booleanValue) low = mid + 1;
else high = mid - …Run Code Online (Sandbox Code Playgroud) 我希望模拟对象在每个方法调用上返回不同的值。但是该方法没有参数。下面是一个例子:
public class MyClass {
public double getValue() {
return 0;
}
}
public class IteratorClass {
MyClass myClass;
public IteratorClass(MyClass myClass) {
this.myClass = myClass;
}
public void iterate() {
for (int i = 0; i < 5; i++) {
System.out.println("myClass.getValue() = " + myClass.getValue());
}
}
}
public class IteratorClassTest {
private MyClass myClass;
private IteratorClass iteratorClass;
@Before
public void setUp() throws Exception {
myClass = mock(MyClass.class);
iteratorClass = spy(new IteratorClass(myClass));
}
@Test
public void testIterate() throws Exception …Run Code Online (Sandbox Code Playgroud) 我ArithmeticProblem在 TestFX 中为类编写了一个单元测试。
public class ArithmeticProblemTextFx extends TestFxBase {
@Test(expected = FxRobotException.class)
public void fxIdNotExist() {
clickOn("#test123");
}
@Test
public void allComponentsShouldHaveRightText() {
verifyThat("#jfxButtonCheck", hasText("PRÜFEN"));
verifyThat("#jfxButtonNextArithmeticProblem", hasText("NÄCHSTE AUFGABE"));
verifyThat("#jfxButtonSave", hasText("SPEICHERN"));
verifyThat("#jfxTextFieldResult", hasText(""));
}
@Test
public void checkTextFieldResult() {
JFXTextField jfxTextFieldResult = find("#jfxTextFieldResult");
JFXButton jfxButtonCheck = find("#jfxButtonCheck");
jfxTextFieldResult.setText("5");
assertFalse(
"Der Button ist darf NICHT disable sein, da eine Zahl in TextFieldResult steht.",
jfxButtonCheck.isDisable()
);
jfxTextFieldResult.setText("g");
assertTrue(
"Der Button muss disable sein, da KEINE Zahl in TextFieldResult steht.",
jfxButtonCheck.isDisable()
); …Run Code Online (Sandbox Code Playgroud)