Three refugees have been arrested in Germany on suspicion of planning a terrorist attack, federal prosecutors said.