Java 类org.assertj.core.api.Java6Assertions 实例源码

项目:tifoon    文件:ReflectionObjectTreeAwareTest.java   
@Test
public void testTracePathFromProtocol() throws UnknownHostException {
    final Port port1 = Port.from(Protocol.TCP, 23);
    final Port port2 = Port.from(Protocol.UDP, 53);

    final Map<InetAddress, List<Port>> inetAddressPortMap = new HashMap<>();
    inetAddressPortMap.put(InetAddress.getByName("1.5.3.6"), Arrays.asList(port1, port2));

    final NetworkResult networkResult1 = new NetworkResult("network1", true, Collections.EMPTY_MAP);
    final NetworkResult networkResult2 = new NetworkResult("network2", true, Collections.EMPTY_MAP);
    final NetworkResult networkResult3 = new NetworkResult("network3", true, inetAddressPortMap);

    final List<NetworkResult> networkResults = Arrays.asList(networkResult1, networkResult2, networkResult3);

    final PortScannerResult portScannerResult = new PortScannerResult(UUID.randomUUID().toString(), 0, 0, PortScannerStatus.DONE, Collections.EMPTY_LIST, "", networkResults);

    final List<ObjectTreeAware> path = portScannerResult.traceObjectPath(networkResult3.getOpenHosts().get("1.5.3.6").getOpenPorts().values().stream().collect(Collectors.toList()).get(0).getProtocol());

    Java6Assertions.assertThat(path).as("object path from port2 protocol to root").containsExactly(
            port2,
            networkResult3.getOpenHosts().get("1.5.3.6"),
            networkResult3,
            portScannerResult);
}
项目:tifoon    文件:ReflectionObjectTreeAwareTest.java   
@Test
public void testTracePathFromHost() throws UnknownHostException {
    final Port port1 = Port.from(Protocol.TCP, 23);
    final Port port2 = Port.from(Protocol.UDP, 53);

    final Map<InetAddress, List<Port>> inetAddressPortMap = new HashMap<>();
    inetAddressPortMap.put(InetAddress.getByName("1.5.3.6"), Collections.singletonList(port1));
    inetAddressPortMap.put(InetAddress.getByName("3.88.7.5"), Collections.singletonList(port2));

    final NetworkResult networkResult1 = new NetworkResult("network1", true, Collections.EMPTY_MAP);
    final NetworkResult networkResult2 = new NetworkResult("network2", true, inetAddressPortMap);

    final List<NetworkResult> networkResults = Arrays.asList(networkResult1, networkResult2);

    final PortScannerResult portScannerResult = new PortScannerResult(UUID.randomUUID().toString(), 0, 0, PortScannerStatus.DONE, Collections.EMPTY_LIST, "", networkResults);

    final List<ObjectTreeAware> path = portScannerResult.traceObjectPath(networkResult2.getOpenHosts().get("3.88.7.5"));

    Java6Assertions.assertThat(path).as("object path from host 3.88.7.5 to root").containsExactly(
            networkResult2,
            portScannerResult);
}
项目:tifoon    文件:NetworkResultTest.java   
@Test
public void testJsonConverterWithOpenHosts() throws IOException {
    final Port port1 = Port.from(Protocol.TCP, 23);
    final Port port2 = Port.from(Protocol.TCP, 132);
    final Port port3 = Port.from(Protocol.TCP, 1234);

    final HashMap<InetAddress, List<Port>> inetAddressPortMap = new HashMap<>();
    inetAddressPortMap.put(InetAddress.getByName("1.5.3.6"), Arrays.asList(port1, port2));
    inetAddressPortMap.put(InetAddress.getByName("35.74.52.5"), Collections.singletonList(port3));

    final NetworkResult networkResult = new NetworkResult("test", true, inetAddressPortMap);

    final HashMap<String, OpenHost> openHosts = networkResult.getOpenHosts();

    Java6Assertions.assertThat(openHosts).as("openHosts should not be empty").isNotEmpty();

    testJsonSerializationDeserialization(openHosts);
}
项目:tifoon    文件:ReflectionObjectTreeAwareTest.java   
@Test
public void testTracePathFromEntity() {
    final PortScannerResult portScannerResult = new PortScannerResult(UUID.randomUUID().toString(), 0, 0, PortScannerStatus.DONE, Collections.EMPTY_LIST, "", Collections.EMPTY_LIST);

    final List<ObjectTreeAware> path = portScannerResult.traceObjectPath(portScannerResult.getNetworkResults());

    Java6Assertions.assertThat(path).as("path should only contain the entity itself").containsExactly(portScannerResult);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindInPath() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, "networkResults.*", null, null, null, null);
    final String key = PortScannerResult.class.getCanonicalName();

    Java6Assertions.assertThat(propertyChanges).hasSize(6).containsAll(portScannerDiff.getEntityChangeMap().get(key).getChanges());
}
项目:estatio    文件:Applicability_Test.java   
@Test
public void happy_case() throws Exception {

    // when
    final Applicability applicability =
            new Applicability(mockDocumentTemplate,
                    SomeDomainObject.class, SomeRendererModelFactory.class, SomeAttachmentAdvisor.class);

    // then
    Java6Assertions.assertThat(applicability.getDocumentTemplate()).isEqualTo(mockDocumentTemplate);
    Java6Assertions.assertThat(applicability.getDomainClassName()).isEqualTo(SomeDomainObject.class.getName());
    Java6Assertions.assertThat(applicability.getRendererModelFactoryClassName()).isEqualTo(SomeRendererModelFactory.class.getName());
    Java6Assertions.assertThat(applicability.getAttachmentAdvisorClassName()).isEqualTo(SomeAttachmentAdvisor.class.getName());

}
项目:FitBuddy    文件:BasicSetsTest.java   
@Test
public void containsSet_shouldReturnBoolean() throws Exception {
    Set set = aSet().build();
    Sets sets = new BasicSets(new ArrayList<>());
    sets.add(set);

    Java6Assertions.assertThat(sets.contains(null)).isFalse();
    Java6Assertions.assertThat(sets.contains(aSet().build())).isFalse();
    Java6Assertions.assertThat(sets.contains(set)).isTrue();
}
项目:tifoon    文件:NetworkResultTest.java   
@Test
public void testCanConstructWithSuccessFalse() {
    final NetworkResult networkResult = new NetworkResult("test", false, Collections.EMPTY_MAP);

    Java6Assertions.assertThat(networkResult.isSuccess()).as("object should be valid with success=false").isEqualTo(false);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindExactInPath() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, "networkResults/1", null, null, null, null);

    Java6Assertions.assertThat(propertyChanges).containsExactly(propertyChange4, propertyChange0, propertyChange2);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testNoMatchInPath() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, "foobar", null, null, null, null);

    Java6Assertions.assertThat(propertyChanges).isEmpty();
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindProperty() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, "someProperty", null, null, null);

    Java6Assertions.assertThat(propertyChanges).containsExactly(propertyChange5);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testCannotFindProperty() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, "someUnkownnProperty", null, null, null);

    Java6Assertions.assertThat(propertyChanges).isEmpty();
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindKey() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, "0", null, null);

    Java6Assertions.assertThat(propertyChanges).containsExactly(propertyChange3, propertyChange2, propertyChange1);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testCannotFindKey() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, "someUnknownKey", null, null);

    Java6Assertions.assertThat(propertyChanges).isEmpty();
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindType() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, null, Type.OBJECT, null);

    Java6Assertions.assertThat(propertyChanges).containsExactly(propertyChange5, propertyChange4, propertyChange0);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testCannotFindType() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, null, Type.ARRAY, null);

    Java6Assertions.assertThat(propertyChanges).isEmpty();
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindOperation() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, null, null, Operation.VALUE_MODIFICATION);

    Java6Assertions.assertThat(propertyChanges).containsExactly(propertyChange5, propertyChange0);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testFindCombinationOfCollectionAndAddition() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, null, Type.COLLECTION, Operation.ADDITION);

    Java6Assertions.assertThat(propertyChanges).containsExactly(propertyChange3, propertyChange2, propertyChange1);
}
项目:tifoon    文件:PortScannerDiffTest.java   
@Test
public void testCannotFindCombinationOfCollectionAndRemoval() {
    final List<PropertyChange> propertyChanges = portScannerDiff.findPropertyChanges(PortScannerResult.class, null, null, null, Type.COLLECTION, Operation.REMOVAL);

    Java6Assertions.assertThat(propertyChanges).isEmpty();
}
项目:tifoon    文件:ReflectionObjectTreeAwareTest.java   
@Test
public void testTracePathFromUnrelatedObjectReturnsNull() {
    final PortScannerResult portScannerResult = new PortScannerResult(UUID.randomUUID().toString(), 0, 0, PortScannerStatus.DONE, Collections.EMPTY_LIST, "", Collections.EMPTY_LIST);

    final NetworkResult unrelatedNetworkResult = new NetworkResult("network1", true, Collections.EMPTY_MAP);

    final List<ObjectTreeAware> path = portScannerResult.traceObjectPath(unrelatedNetworkResult);

    Java6Assertions.assertThat(path).as("the path to an unrelated object must be null").isNull();
}
项目:tifoon    文件:NetworkResultTest.java   
@Test
public void testJsonConverterWithNoOpenHosts() throws IOException {
    final NetworkResult networkResult = new NetworkResult("test", true, Collections.EMPTY_MAP);

    final HashMap<String, OpenHost> openHosts = networkResult.getOpenHosts();

    Java6Assertions.assertThat(openHosts).as("openHosts should be empty").isEmpty();

    testJsonSerializationDeserialization(openHosts);
}