@Component
@RestController
public class Worker {
@RequestMapping(path = "/one", method = RequestMethod.GET)
public Model findOne() throws IOException {
}
public class WorkerTests {
@Autowired
private MockMvc mockMvc;
@MockBean
Worker worker;
private final String URL = "/one";
@Test
public void test() throws Exception {
// запрограммировать ответ кода позовут
when(worker.findOne()).thenReturn(new Model(1, "stub"));
// позвать
MvcResult result = mockMvc.perform(
MockMvcRequestBuilders.get(URL).accept(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
// HTTP статус
assertEquals("Incorrect Response Status", HttpStatus.OK.value(), result.getResponse().getStatus());
// вызов метода
verify(worker).findOne();
// валидный ответ
assertNotNull(jsonToObject(result.getResponse().getContentAsString(), Model.class));
// и мок Model придет назад с id как задумано
Model response = jsonToObject(result.getResponse().getContentAsString(), Model.class);
assertEquals(1, response.getId());
}
vagrant ssh имя ноды
ssh -p порт vagrant@127.0.0.1
wmic:root\cli>path win32_process where (processid = 5640)
Caption CommandLine
ssh.exe "C:\Program Files\Git\usr\bin\ssh.EXE" vagrant@127.0.0.1 -p 2222
jTextField1.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
jTextField1ActionPerformed(e);
}
public void focusLost(FocusEvent e) {
}
void displayMessage(String prefix, FocusEvent e) {
}
});
jTextField1.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
System.err.println("text:" + text);
textField.setText(text.toUpperCase());
}
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
});
private Locale locale = new Locale("en", "US");
private void jTextField1ActionPerformed(FocusEvent evt) {
System.err.println("Locale is: " + jTextField1.getLocale());
}
System.err.println("Locale was: " + jTextField1.getInputContext().getLocale());
Locale locale = new Locale("ru", "RU");
Locale.setDefault(locale);
jTextField1.setLocale(locale);
System.err.println("Locale changed to: " + jTextField1.getLocale());
Locale was: en_US
Locale changed to: ru_RU
By.cssSelector
package example;
public class Controller {
@FXML
private Button buttonSave;
@FXML
private TextField textField;
public void actionButtonPressed(ActionEvent event) {
Object source = event.getSource();
if (!(source instanceof Button)) {
return;
}
Button button = (Button) source;
System.err.println("Data: " + textField.getText() + " clicked:" + button.getId());
}
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="502.0" prefWidth="529.0" style="-fx-background-color: #FAF9F0;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="example.Controller">
...
<TextField layoutX="106.0" layoutY="215.0" opacity="0.8" prefHeight="70.0" prefWidth="300.0" promptText="Срок в месяцах"
fx:id="textField">
<font>
<Font name="VAG World Bold" size="11.0" />
</font>
</TextField>
<Button layoutX="106.0" layoutY="303.0" mnemonicParsing="false" prefHeight="70.0" prefWidth="300.0" style="-fx-background-color: #00B850; -fx-cursor: hand;"
text="Посчитать" textFill="WHITE"
fx:id="buttonSave" onAction="#actionButtonPressed">
<font>
<Font name="VAG World Bold" size="20.0" />
</font>
</Button>
final String script = "return arguments[0].value";
WebElement element = driver.findElement(By.cssSelector("input[name=\"clock\"]"));
String value = (String) executeScript(script, element);
System.err.println("current value: " + value);
WebElement element = driver.findElement(By.cssSelector("input[name=\"clock\"]"));
String value = element.getAttribute("value");
System.err.println("current value: " + value);