Search in sources :

Example 1 with MockParameterService

use of org.jumpmind.symmetric.service.impl.MockParameterService in project symmetric-ds by JumpMind.

the class DefaultNodeIdCreatorTest method testSelectNodeId.

@Test
public void testSelectNodeId() throws Exception {
    final String EXPECTED_NODE_ID = "100-2";
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(), new MockNodeService() {

        @Override
        public NodeSecurity findNodeSecurity(String nodeId) {
            if (nodeId.equals(EXPECTED_NODE_ID)) {
                NodeSecurity security = new NodeSecurity();
                security.setNodeId(EXPECTED_NODE_ID);
                security.setRegistrationEnabled(true);
                return security;
            } else {
                return null;
            }
        }
    }, SecurityServiceFactory.create());
    Node node = new Node();
    node.setExternalId("100");
    String selectedNodeId = generator.selectNodeId(node, null, null);
    assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}
Also used : MockNodeService(org.jumpmind.symmetric.service.impl.MockNodeService) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) MockParameterService(org.jumpmind.symmetric.service.impl.MockParameterService) Node(org.jumpmind.symmetric.model.Node) Test(org.junit.Test)

Example 2 with MockParameterService

use of org.jumpmind.symmetric.service.impl.MockParameterService in project symmetric-ds by JumpMind.

the class DefaultNodeIdCreatorTest method testSelectNodeIdWithNodeIdSet.

@Test
public void testSelectNodeIdWithNodeIdSet() throws Exception {
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(), new MockNodeService(), SecurityServiceFactory.create());
    Node node = new Node();
    final String EXPECTED_NODE_ID = "10001";
    node.setExternalId(EXPECTED_NODE_ID);
    node.setNodeId(EXPECTED_NODE_ID);
    String selectedNodeId = generator.selectNodeId(node, null, null);
    assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}
Also used : MockNodeService(org.jumpmind.symmetric.service.impl.MockNodeService) MockParameterService(org.jumpmind.symmetric.service.impl.MockParameterService) Node(org.jumpmind.symmetric.model.Node) Test(org.junit.Test)

Example 3 with MockParameterService

use of org.jumpmind.symmetric.service.impl.MockParameterService in project symmetric-ds by JumpMind.

the class DefaultNodeIdCreatorTest method testGenerateNodeIdNoExisting.

@Test
public void testGenerateNodeIdNoExisting() throws Exception {
    final String EXPECTED_NODE_ID = "100";
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(), new MockNodeService(), SecurityServiceFactory.create());
    Node node = new Node();
    node.setExternalId("100");
    String selectedNodeId = generator.generateNodeId(node, null, null);
    assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}
Also used : MockNodeService(org.jumpmind.symmetric.service.impl.MockNodeService) MockParameterService(org.jumpmind.symmetric.service.impl.MockParameterService) Node(org.jumpmind.symmetric.model.Node) Test(org.junit.Test)

Example 4 with MockParameterService

use of org.jumpmind.symmetric.service.impl.MockParameterService in project symmetric-ds by JumpMind.

the class DefaultNodeIdCreatorTest method testGenerateNodeIdWithNodeIdSet.

@Test
public void testGenerateNodeIdWithNodeIdSet() throws Exception {
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(), new MockNodeService(), SecurityServiceFactory.create());
    Node node = new Node();
    final String EXPECTED_NODE_ID = "10001";
    node.setExternalId(EXPECTED_NODE_ID);
    node.setNodeId(EXPECTED_NODE_ID);
    String selectedNodeId = generator.generateNodeId(node, null, null);
    assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}
Also used : MockNodeService(org.jumpmind.symmetric.service.impl.MockNodeService) MockParameterService(org.jumpmind.symmetric.service.impl.MockParameterService) Node(org.jumpmind.symmetric.model.Node) Test(org.junit.Test)

Example 5 with MockParameterService

use of org.jumpmind.symmetric.service.impl.MockParameterService in project symmetric-ds by JumpMind.

the class DefaultNodeIdCreatorTest method testGenerateNodeIdExisting.

@Test
public void testGenerateNodeIdExisting() throws Exception {
    final String EXPECTED_NODE_ID = "100";
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(ParameterConstants.EXTERNAL_ID_IS_UNIQUE, "true"), new MockNodeService() {

        @Override
        public Node findNode(String nodeId) {
            if (nodeId.equals("100")) {
                Node node = new Node();
                node.setNodeId("100");
                return node;
            } else {
                return null;
            }
        }
    }, SecurityServiceFactory.create());
    Node node = new Node();
    node.setExternalId("100");
    String selectedNodeId = generator.generateNodeId(node, null, null);
    assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}
Also used : MockNodeService(org.jumpmind.symmetric.service.impl.MockNodeService) MockParameterService(org.jumpmind.symmetric.service.impl.MockParameterService) Node(org.jumpmind.symmetric.model.Node) Test(org.junit.Test)

Aggregations

Node (org.jumpmind.symmetric.model.Node)5 MockNodeService (org.jumpmind.symmetric.service.impl.MockNodeService)5 MockParameterService (org.jumpmind.symmetric.service.impl.MockParameterService)5 Test (org.junit.Test)5 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1