Ejemplo n.º 1
0
  @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());
  }
Ejemplo n.º 2
0
  @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());
  }