ShardRedeployOperation extends AbstractShardOperation { @Override protected void execute(NodeContext context, String shardName, DeployResult deployResult) throws Exception { File localShardFolder = context.getShardManager().getShardFolder(shardName); IContentServer contentServer = context.getContentServer(); if (!contentServer.getShards().contains(shardName)) { contentServer.addShard(shardName, localShardFolder); } publishShard(shardName, context); } ShardRedeployOperation(Collection<String> installedShards);   }
@Test public void testRedeploy() throws Exception { List<String> shards = Arrays.asList("shard1", "shard2"); ShardRedeployOperation operation = new ShardRedeployOperation(shards); operation.execute(_context); InOrder inOrder = inOrder(_protocol, _contentServer); for (String shard : shards) { inOrder.verify(_contentServer).addShard(eq(shard), (File) notNull()); inOrder.verify(_protocol).publishShard(eq(_node), eq(shard)); } }
@Test public void testRedeployShardAlreadyKnownToNodeManaged() throws Exception { List<String> shards = Arrays.asList("shard1", "shard2"); when(_contentServer.getShards()).thenReturn(shards); ShardRedeployOperation operation = new ShardRedeployOperation(shards); operation.execute(_context); InOrder inOrder = inOrder(_protocol, _contentServer); for (String shard : shards) { inOrder.verify(_protocol).publishShard(eq(_node), eq(shard)); } }