本文整理汇总了Java中org.junit.experimental.theories.FromDataPoints类的典型用法代码示例。如果您正苦于以下问题:Java FromDataPoints类的具体用法?Java FromDataPoints怎么用?Java FromDataPoints使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FromDataPoints类属于org.junit.experimental.theories包,在下文中一共展示了FromDataPoints类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMapStrProperty
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testMapStrProperty(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableMap<String, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
ObservableMap<String, CustomObject> mapOne = FXCollections.observableHashMap();
mapOne.put("key1", one);
ObservableMap<String, CustomObject> mapTwo = FXCollections.observableHashMap();
mapTwo.put("key1", one);
mapTwo.put("key2", two);
testProperty(WithMapStrProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
testProperty(WithMapStrProp.class, mapEmpty, "{\"prop\":{}}", o -> o.prop, gson);
testProperty(WithMapStrProp.class, mapOne, "{\"prop\":{\"key1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
testProperty(WithMapStrProp.class, mapTwo,
"{\"prop\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
示例2: shouldAssociativelyResolveEqualViewsToTrue
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void shouldAssociativelyResolveEqualViewsToTrue(@FromDataPoints("eq left") View<TestNode> left,
@FromDataPoints("eq left") View<TestNode> right) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, false);
// when
View<TestNode> leftToRight = new EqualsExpr(leftExpr, rightExpr).resolve(context);
View<TestNode> rightToLeft = new EqualsExpr(rightExpr, leftExpr).resolve(context);
// then
assertThat(leftToRight).isEqualTo(BooleanView.of(true));
assertThat(rightToLeft).isEqualTo(BooleanView.of(true));
}
示例3: shouldAssociativelyResolveNonEqualViewsToFalse
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void shouldAssociativelyResolveNonEqualViewsToFalse(@FromDataPoints("eq left") View<TestNode> left,
@FromDataPoints("eq right") View<TestNode> right) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, false);
// when
View<TestNode> leftToRight = new EqualsExpr(leftExpr, rightExpr).resolve(context);
View<TestNode> rightToLeft = new EqualsExpr(rightExpr, leftExpr).resolve(context);
// then
assertThat(leftToRight).isEqualTo(BooleanView.of(false));
assertThat(rightToLeft).isEqualTo(BooleanView.of(false));
}
示例4: shouldApplyRightViewToLeftViewWhenShouldCreate
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void shouldApplyRightViewToLeftViewWhenShouldCreate(@FromDataPoints("eq left") View<TestNode> left,
@FromDataPoints("eq right") View<TestNode> right) {
// given
if (!(left instanceof NodeView)
&& (!(left instanceof NodeSetView) || !(((NodeSetView) left).iterator().next() instanceof NodeView))) {
expectedException.expect(XmlBuilderException.class);
}
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, true);
// when
View<TestNode> result = new EqualsExpr(leftExpr, rightExpr).resolve(context);
// then
assertThat(result).isEqualTo(BooleanView.of(true));
verify(navigator).setText(any(TestNode.class), eq(right.toString()));
}
示例5: shouldAssociativelyResolveEqualViewsToFalse
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void shouldAssociativelyResolveEqualViewsToFalse(@FromDataPoints("ne left") View<TestNode> left,
@FromDataPoints("ne left") View<TestNode> right) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, false);
// when
View<TestNode> leftToRight = new NotEqualsExpr(leftExpr, rightExpr).resolve(context);
View<TestNode> rightToLeft = new NotEqualsExpr(rightExpr, leftExpr).resolve(context);
// then
assertThat(leftToRight).isEqualTo(BooleanView.of(false));
assertThat(rightToLeft).isEqualTo(BooleanView.of(false));
}
示例6: shouldAssociativelyResolveNonEqualViewsToTrue
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void shouldAssociativelyResolveNonEqualViewsToTrue(@FromDataPoints("ne left") View<TestNode> left,
@FromDataPoints("ne right") View<TestNode> right) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, false);
// when
View<TestNode> leftToRight = new NotEqualsExpr(leftExpr, rightExpr).resolve(context);
View<TestNode> rightToLeft = new NotEqualsExpr(rightExpr, leftExpr).resolve(context);
// then
assertThat(leftToRight).isEqualTo(BooleanView.of(true));
assertThat(rightToLeft).isEqualTo(BooleanView.of(true));
}
示例7: shouldApplyRightViewToLeftViewWhenShouldCreate
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void shouldApplyRightViewToLeftViewWhenShouldCreate(@FromDataPoints("ne left") View<TestNode> left,
@FromDataPoints("ne left") View<TestNode> right) {
// given
if (!(left instanceof NodeView)
&& (!(left instanceof NodeSetView) || !(((NodeSetView) left).iterator().next() instanceof NodeView))) {
expectedException.expect(XmlBuilderException.class);
}
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, true);
// when
View<TestNode> result = new NotEqualsExpr(leftExpr, rightExpr).resolve(context);
// then
assertThat(result).isEqualTo(BooleanView.of(true));
verify(navigator).setText(any(TestNode.class), eq(Boolean.toString(!right.toBoolean())));
}
示例8: findByName
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void findByName(@FromDataPoints("responses")
ResponseEntity<CredentialSummaryData> expectedResponse) {
when(restTemplate.getForEntity(NAME_LIKE_URL_QUERY, CredentialSummaryData.class, NAME.getName()))
.thenReturn(expectedResponse);
if (!expectedResponse.getStatusCode().equals(OK)) {
try {
credHubTemplate.findByName(NAME);
fail("Exception should have been thrown");
}
catch (CredHubException e) {
assertThat(e.getMessage(), containsString(expectedResponse.getStatusCode().toString()));
}
}
else {
List<CredentialSummary> response = credHubTemplate.findByName(NAME);
assertResponseContainsExpectedCredentials(expectedResponse, response);
}
}
示例9: findByPath
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void findByPath(@FromDataPoints("responses")
ResponseEntity<CredentialSummaryData> expectedResponse) {
when(restTemplate.getForEntity(PATH_URL_QUERY, CredentialSummaryData.class, NAME.getName()))
.thenReturn(expectedResponse);
if (!expectedResponse.getStatusCode().equals(OK)) {
try {
credHubTemplate.findByPath(NAME.getName());
fail("Exception should have been thrown");
}
catch (CredHubException e) {
assertThat(e.getMessage(), containsString(expectedResponse.getStatusCode().toString()));
}
}
else {
List<CredentialSummary> response = credHubTemplate.findByPath(NAME.getName());
assertResponseContainsExpectedCredentials(expectedResponse, response);
}
}
示例10: testObservableList
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testObservableList(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableList<CustomObject> listEmpty = FXCollections.observableArrayList();
ObservableList<CustomObject> listOne = FXCollections.observableArrayList(one);
ObservableList<CustomObject> listTwo = FXCollections.observableArrayList(one, two);
Function<WithObsList, ObservableList<CustomObject>> getter = o -> o.list;
BiConsumer<WithObsList, ObservableList<CustomObject>> setter = (o, l) -> o.list = l;
testValue(WithObsList.class, null, "{\"list\":null}", getter, setter, gson);
testValue(WithObsList.class, listEmpty, "{\"list\":[]}", getter, setter, gson);
testValue(WithObsList.class, listOne, "{\"list\":[{\"name\":\"myObj1\"}]}", getter, setter, gson);
testValue(WithObsList.class, listTwo, "{\"list\":[{\"name\":\"myObj1\"},{\"name\":\"myObj2\"}]}", getter,
setter, gson);
}
示例11: testObservableSet
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testObservableSet(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableSet<CustomObject> setEmpty = FXCollections.emptyObservableSet();
ObservableSet<CustomObject> setOne = FXCollections.observableSet(one);
ObservableSet<CustomObject> setTwo = FXCollections.observableSet(one, two);
Function<WithObsSet, ObservableSet<CustomObject>> getter = o -> o.set;
BiConsumer<WithObsSet, ObservableSet<CustomObject>> setter = (o, s) -> o.set = s;
testValue(WithObsSet.class, null, "{\"set\":null}", getter, setter, gson);
testValue(WithObsSet.class, setEmpty, "{\"set\":[]}", getter, setter, gson);
testValue(WithObsSet.class, setOne, "{\"set\":[{\"name\":\"myObj1\"}]}", getter, setter, gson);
// do not check a particular JSON because the order is non-deterministic
testValue(WithObsSet.class, setTwo, null, getter, setter, gson);
}
示例12: testObservableMapStr
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testObservableMapStr(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableMap<String, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
ObservableMap<String, CustomObject> mapOne = FXCollections.observableHashMap();
mapOne.put("key1", one);
ObservableMap<String, CustomObject> mapTwo = FXCollections.observableHashMap();
mapTwo.put("key1", one);
mapTwo.put("key2", two);
Function<WithObsMapStr, ObservableMap<String, CustomObject>> getter = o -> o.map;
BiConsumer<WithObsMapStr, ObservableMap<String, CustomObject>> setter = (o, m) -> o.map = m;
testValue(WithObsMapStr.class, null, "{\"map\":null}", getter, setter, gson);
testValue(WithObsMapStr.class, mapEmpty, "{\"map\":{}}", getter, setter, gson);
testValue(WithObsMapStr.class, mapOne, "{\"map\":{\"key1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
testValue(WithObsMapStr.class, mapTwo,
"{\"map\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", getter, setter, gson);
}
示例13: testMapIntProperty
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testMapIntProperty(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableMap<Integer, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
ObservableMap<Integer, CustomObject> mapOne = FXCollections.observableHashMap();
mapOne.put(1, one);
ObservableMap<Integer, CustomObject> mapTwo = FXCollections.observableHashMap();
mapTwo.put(1, one);
mapTwo.put(2, two);
testProperty(WithMapIntProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
testProperty(WithMapIntProp.class, mapEmpty, "{\"prop\":{}}", o -> o.prop, gson);
testProperty(WithMapIntProp.class, mapOne, "{\"prop\":{\"1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
testProperty(WithMapIntProp.class, mapTwo,
"{\"prop\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
示例14: testObservableMapInt
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testObservableMapInt(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableMap<Integer, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
ObservableMap<Integer, CustomObject> mapOne = FXCollections.observableHashMap();
mapOne.put(1, one);
ObservableMap<Integer, CustomObject> mapTwo = FXCollections.observableHashMap();
mapTwo.put(1, one);
mapTwo.put(2, two);
Function<WithObsMapInt, ObservableMap<Integer, CustomObject>> getter = o -> o.map;
BiConsumer<WithObsMapInt, ObservableMap<Integer, CustomObject>> setter = (o, m) -> o.map = m;
testValue(WithObsMapInt.class, null, "{\"map\":null}", getter, setter, gson);
testValue(WithObsMapInt.class, mapEmpty, "{\"map\":{}}", getter, setter, gson);
testValue(WithObsMapInt.class, mapOne, "{\"map\":{\"1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
testValue(WithObsMapInt.class, mapTwo, "{\"map\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}",
getter, setter, gson);
}
示例15: testCustomTreeMapStrProperty
import org.junit.experimental.theories.FromDataPoints; //导入依赖的package包/类
@Theory
public void testCustomTreeMapStrProperty(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
Map<String, CustomObject> mapEmpty = new TreeMap<>();
Map<String, CustomObject> mapOne = new TreeMap<>();
mapOne.put("key1", one);
Map<String, CustomObject> mapTwo = new TreeMap<>();
mapTwo.put("key1", one);
mapTwo.put("key2", two);
ObservableMap<String, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
ObservableMap<String, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
ObservableMap<String, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);
testProperty(WithMapStrProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
testProperty(WithMapStrProp.class, mapEmptyObs, "{\"prop\":{}}", o -> o.prop, gson);
testProperty(WithMapStrProp.class, mapOneObs, "{\"prop\":{\"key1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
testProperty(WithMapStrProp.class, mapTwoObs,
"{\"prop\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}