@Test public void musicNoteReadTest3() throws Exception { assertAmbiguityFree(parser, "2Ebb"); // Nos garantiza que es válido y no hay ambigüedades MusicNote note = parser.parse("2Ebb"); assertTrue(note instanceof AbsoluteMusicNote); AbsoluteMusicNote aNote = (AbsoluteMusicNote) note; assertEquals(2, aNote.getOctave().intValue()); assertTrue( aNote.getMusicNoteName() instanceof AlteredNoteName); // Idem, tienes que implementar getNoteName() AlteredNoteName altNoteName = (AlteredNoteName) aNote.getMusicNoteName(); BasicNoteName bNoteName = altNoteName.getBasicNoteName(); assertEquals( "E", bNoteName .getValue()); // Implementa ese getValue también, así es independiente del toString (que // da la traducción a lilypond y que podría cambiar en un futuro). Alteration alteration = altNoteName.getAlteration(); assertTrue(alteration instanceof DoubleFlatAlteration); DoubleFlatAlteration dSharpAlteration = (DoubleFlatAlteration) alteration; assertEquals("bb", dSharpAlteration.getValue()); }
@Test public void musicNoteReadTest7() throws Exception { assertAmbiguityFree(parser, "G"); // Nos garantiza que es válido y no hay ambigüedades MusicNote note = parser.parse("G"); assertTrue(note instanceof RelativeMusicNote); RelativeMusicNote rNote = (RelativeMusicNote) note; // Check the alteration assertNull(rNote.getOctave()); MusicNoteName mNoteName = rNote.getMusicNoteName(); assertTrue(mNoteName instanceof BasicNoteName); BasicNoteName bNoteName = (BasicNoteName) mNoteName; assertEquals("G", bNoteName.getValue()); }
// Comprobamos si la información leída de una nota es correcta: @Test public void musicNoteReadTest1() throws Exception { assertAmbiguityFree(parser, "-2D"); // Nos garantiza que es válido y no hay ambigüedades MusicNote note = parser.parse("-2D"); assertTrue(note instanceof AbsoluteMusicNote); AbsoluteMusicNote aNote = (AbsoluteMusicNote) note; assertEquals(-2, aNote.getOctave().intValue()); assertTrue( aNote.getMusicNoteName() instanceof BasicNoteName); // Idem, tienes que implementar getNoteName() BasicNoteName bNoteName = (BasicNoteName) aNote.getMusicNoteName(); assertEquals( "D", bNoteName .getValue()); // Implementa ese getValue también, así es independiente del toString (que // da la traducción a lilypond y que podría cambiar en un futuro). }
@Test public void musicNoteReadTest4() throws Exception { assertAmbiguityFree(parser, "A#"); // Nos garantiza que es válido y no hay ambigüedades MusicNote note = parser.parse("A#"); assertTrue(note instanceof RelativeMusicNote); RelativeMusicNote rNote = (RelativeMusicNote) note; assertNull(rNote.getOctave()); MusicNoteName mNoteName = rNote.getMusicNoteName(); assertTrue(mNoteName instanceof AlteredNoteName); AlteredNoteName altNoteName = (AlteredNoteName) mNoteName; assertEquals("A", altNoteName.getBasicNoteName().getValue()); Alteration alteration = altNoteName.getAlteration(); assertTrue(alteration instanceof SharpAlteration); SharpAlteration sharpAlteration = (SharpAlteration) alteration; assertEquals("#", sharpAlteration.getValue()); }