我有以下HTML:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript & jQuery - Chapter 13: Form Enhancement and Validation - Select All Checkboxes</title>
<link rel="stylesheet" href="css/c13.css" />
</head>
<body>
<div class="container login">
<form id="interests" action="/login" method="post">
<div class="one-third column">
<img src="img/logo.png" alt="logo" id="logo" />
</div>
<div class="two-thirds column" id="main">
<fieldset>
<legend>Genres</legend>
<label><input type="checkbox" value="all" id="all">All</label>
<label><input type="checkbox" name="genre" value="animation">Animation</label>
<label><input type="checkbox" name="genre" value="docs">Documentary</label>
<label><input type="checkbox" name="genre" value="shorts">Shorts</label>
</fieldset>
</div><!-- .two-thirds -->
</form>
</div><!-- .container -->
<script src="js/utilities.js"></script>
<script src="js/all-checkboxes.js"></script>
</body>
Run Code Online (Sandbox Code Playgroud)
在all-checkbox.js文件中,我有以下几行:
...
var form …Run Code Online (Sandbox Code Playgroud) 我正在看Mainak Mitra撰写的Mastering Gradle的Gradle构建文件中的自定义任务的简单示例(第70页)。构建脚本为:
println "Working on custom task in build script"
class SampleTask extends DefaultTask {
String systemName = "DefaultMachineName"
String systemGroup = "DefaultSystemGroup"
@TaskAction
def action1() {
println "System Name is "+systemName+" and group is "+systemGroup
}
@TaskAction
def action2() {
println 'Adding multiple actions for refactoring'
}
}
task hello(type: SampleTask)
hello {
systemName='MyDevelopmentMachine'
systemGroup='Development'
}
hello.doFirst {println "Executing first statement "}
hello.doLast {println "Executing last statement "}
Run Code Online (Sandbox Code Playgroud)
如果我使用gradle -q:hello运行构建脚本,则输出为:
Executing first statement
System Name is MyDevelopmentMachine and …Run Code Online (Sandbox Code Playgroud) 我有一个测试来验证空对象的返回(如果该对象的字符串属性与预先确定的值不匹配)。我的代码是
import guru.springframework.sfgpetclinic.model.Speciality;
import guru.springframework.sfgpetclinic.repositories.SpecialtyRepository;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.BDDMockito.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
@ExtendWith(MockitoExtension.class)
class SpecialtySDJpaServiceTest {
@Mock
SpecialtyRepository specialtyRepository;
@InjectMocks
SpecialtySDJpaService service;
@Test
void testSaveLambdaNoMatch() {
// Given
final String MATCH_ME = "MATCH_ME";
Speciality speciality = new Speciality();
speciality.setDescription("Not a match");
Speciality savedSpeciality = new Speciality();
savedSpeciality.setId(1L);
// Need mock to only return on match …Run Code Online (Sandbox Code Playgroud)