What you have is a command
object that is of type Commands
. But because of your generic type declaration <C extends Runnable & Describable>
, Java expects C
to be both Describable
and Runnable
, but C
is not necessariy a Commands
.
This particular test method isn't meant to work with anything but Commands
, so it should not be generic. This should work:
public void testMapOfCommands() throws Exception
{
Map<String, Commands> commands = new HashMap<String, Commands>();
for(Commands command : Commands.values())
{
commands.put(command.name(), command);
}
}