Commit 9a6d14bc authored by Michel Schudel's avatar Michel Schudel

method namen van testmethods aangepast.

parent 89eff66f
......@@ -11,7 +11,7 @@ public class BlockchainServiceApplicationIT {
@Test
public void wiring() {
public void allSpringBootWiringIsOk() {
}
}
......@@ -11,7 +11,7 @@ public class BlockTest {
private ObjectMapper objectMapper = new ObjectMapper();
@Test
public void testIfTransactionHasCorrectFormat() throws JsonProcessingException {
public void blockHasCorrectFormat() throws JsonProcessingException {
Block block = new Block();
String blockAsJson = objectMapper.writeValueAsString(block);
assertThat(blockAsJson).isEqualTo("{\"index\":0,\"previousHash\":null,\"proof\":0,\"timestamp\":0,\"transactions\":null}");
......
......@@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class HashUtilTest {
@Test
public void testHash() {
public void stringShouldProduceAHash() {
String hash = HashUtil.createHashOf("I can see my house from here");
assertThat(hash).isEqualTo("c6599690d709c8240563146cf0e04a54cbe3a37b621e5ba8ceb6d5e4d345deae");
}
......
......@@ -101,7 +101,7 @@ public class NetworkTest {
}
@Test
public void registerNewPeer() {
public void peerIsRegisteredAndPropagatedToOtherPeers() {
when(peersRepository.loadPeers()).thenReturn(Stream.of("alreadyKnownPeer:8080").collect(Collectors.toSet()));
Set<String> remotePeers = Stream.of("newRemotePeer:8080").collect(Collectors.toSet());
ResponseEntity<Set<String>> response = new ResponseEntity<>(remotePeers, HttpStatus.OK);
......@@ -117,7 +117,7 @@ public class NetworkTest {
}
@Test
public void notifyPeerOfNewTransaction() {
public void notifyPeerOfNewTransactionShouldPropagateTheTransactionToThePeers() {
when(peersRepository.loadPeers()).thenReturn(Stream.of("alreadyKnownPeer:8080").collect(Collectors.toSet()));
String sourcePeer = "sourcePeer:8080";
Transaction transaction = new Transaction("michel", "jan", BigDecimal.TEN);
......@@ -128,7 +128,7 @@ public class NetworkTest {
}
@Test
public void notifyPeerOfNewBlock() {
public void notifyPeerOfNewBlockShouldPropagateTheBlockToThePeers() {
when(peersRepository.loadPeers()).thenReturn(Stream.of("alreadyKnownPeer:8080").collect(Collectors.toSet()));
String sourcePeer = "sourcePeer:8080";
Block block = new Block();
......@@ -140,7 +140,7 @@ public class NetworkTest {
}
@Test
public void retrieveBlockchainFromPeers() {
public void retrieveBlockchainFromPeersShouldProduceBlockchainList() {
when(peersRepository.loadPeers()).thenReturn(Stream.of("alreadyKnownPeer:8080").collect(Collectors.toSet()));
Blockchain blockchain = new Blockchain();
when(restTemplate.getForObject(eq("http://alreadyKnownPeer:8080/api/blockchain"), eq(Blockchain.class))).thenReturn(blockchain);
......
package nl.craftsmen.blockchain.craftscoinnode.network;
import com.fasterxml.jackson.databind.ObjectMapper;
import nl.craftsmen.blockchain.craftscoinnode.util.InstanceInfo;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.IOException;
import java.nio.file.Files;
......@@ -42,7 +38,7 @@ public class PeersRepositoryTest {
}
@Test
public void testSaveAndLoad() {
public void peerListCanBeSavedAndLoaded() {
when(instanceInfo.getNode()).thenReturn(THISNODE);
Set<String> peers = new HashSet<>();
peers.add(PEERNAME);
......
......@@ -20,14 +20,14 @@ public class InstanceInfoTest {
when(serverProperties.getPort()).thenReturn(8080);
}
@Test
public void testWithAutomaticIpDiscovery() {
public void nonConfiguredIpShouldResultInAutomaticIpDiscovery() {
instanceInfo = new InstanceInfo(serverProperties, null);
instanceInfo.init();
assertThat(instanceInfo.getPort()).isEqualTo(8080);
}
@Test
public void testWithConfiguredIp() {
public void configuredIpShouldProduceThatIpForThisNode() {
instanceInfo = new InstanceInfo(serverProperties, "192.168.0.170");
instanceInfo.init();
assertThat(instanceInfo.getPort()).isEqualTo(8080);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment