@Test public void shouldGenerateCorrectChordInfo(){ List<MetaDataChordInfo> metaDataChordInfos = setMetaDataState.getMetaDataChordInfo(queueState); assertThat(metaDataChordInfos).hasSize(3); assertThat(metaDataChordInfos.get(0).getTrackId()).isEqualToIgnoringCase("some-track-id"); assertThat(metaDataChordInfos.get(0).getPartType()).isEqualToIgnoringCase(ProgressionUnit.ProgressionType.VERSE.toString()); assertThat(metaDataChordInfos.get(0).getPartChords()).isEqualToIgnoringCase("amin7-amin7-cmaj7-amin7"); assertThat(metaDataChordInfos.get(0).getPartKey()).isEqualToIgnoringCase("Gmaj"); assertThat(metaDataChordInfos.get(1).getTrackId()).isEqualToIgnoringCase("some-track-id"); assertThat(metaDataChordInfos.get(1).getPartType()).isEqualToIgnoringCase(ProgressionUnit.ProgressionType.BRIDGE.toString()); assertThat(metaDataChordInfos.get(1).getPartChords()).isEqualToIgnoringCase("bdom7-amin7-bdom7-amin7"); assertThat(metaDataChordInfos.get(1).getPartKey()).isEqualToIgnoringCase("Cmaj"); assertThat(metaDataChordInfos.get(2).getTrackId()).isEqualToIgnoringCase("some-track-id"); assertThat(metaDataChordInfos.get(2).getPartType()).isEqualToIgnoringCase(ProgressionUnit.ProgressionType.CHORUS.toString()); assertThat(metaDataChordInfos.get(2).getPartChords()).isEqualToIgnoringCase("cmaj7-cmaj7-cmaj7-amin7"); assertThat(metaDataChordInfos.get(2).getPartKey()).isEqualToIgnoringCase("amin"); }
public List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState){ List<ProgressionUnit.ProgressionType> finishedTypes = new ArrayList<>(); List<MetaDataChordInfo> metaData = new ArrayList<>(); for (ProgressionUnit pUnit : queueState.getStructure()) { if(finishedTypes.contains(pUnit.getType())){ continue; } MetaDataChordInfo metaDataChordInfo = new MetaDataChordInfo(); metaDataChordInfo.setTrackId(queueState.getQueueItem().getQueueItemId()); metaDataChordInfo.setPartType(pUnit.getType().toString()); metaDataChordInfo.setPartKey(pUnit.getKey()); metaDataChordInfo.setTrackKey("error"); for (ProgressionUnitBar pBar : pUnit.getProgressionUnitBars()) { String chords = metaDataChordInfo.getPartChords(); if(chords == null || chords.equals("")){ metaDataChordInfo.setPartChords(pBar.getChord().getRawChordName()); }else{ metaDataChordInfo.setPartChords(metaDataChordInfo.getPartChords() + "-" + pBar.getChord().getRawChordName()); } } finishedTypes.add(pUnit.getType()); metaData.add(metaDataChordInfo); } return metaData; }
SetMetaDataStateEvent implements IEventChain { public List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState){ List<ProgressionUnit.ProgressionType> finishedTypes = new ArrayList<>(); List<MetaDataChordInfo> metaData = new ArrayList<>(); for (ProgressionUnit pUnit : queueState.getStructure()) { if(finishedTypes.contains(pUnit.getType())){ continue; } MetaDataChordInfo metaDataChordInfo = new MetaDataChordInfo(); metaDataChordInfo.setTrackId(queueState.getQueueItem().getQueueItemId()); metaDataChordInfo.setPartType(pUnit.getType().toString()); metaDataChordInfo.setPartKey(pUnit.getKey()); metaDataChordInfo.setTrackKey("error"); for (ProgressionUnitBar pBar : pUnit.getProgressionUnitBars()) { String chords = metaDataChordInfo.getPartChords(); if(chords == null || chords.equals("")){ metaDataChordInfo.setPartChords(pBar.getChord().getRawChordName()); }else{ metaDataChordInfo.setPartChords(metaDataChordInfo.getPartChords() + "-" + pBar.getChord().getRawChordName()); } } finishedTypes.add(pUnit.getType()); metaData.add(metaDataChordInfo); } return metaData; } }
SetMetaDataStateEvent implements IEventChain { public List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState){ List<ProgressionUnit.ProgressionType> finishedTypes = new ArrayList<>(); List<MetaDataChordInfo> metaData = new ArrayList<>(); for (ProgressionUnit pUnit : queueState.getStructure()) { if(finishedTypes.contains(pUnit.getType())){ continue; } MetaDataChordInfo metaDataChordInfo = new MetaDataChordInfo(); metaDataChordInfo.setTrackId(queueState.getQueueItem().getQueueItemId()); metaDataChordInfo.setPartType(pUnit.getType().toString()); metaDataChordInfo.setPartKey(pUnit.getKey()); metaDataChordInfo.setTrackKey("error"); for (ProgressionUnitBar pBar : pUnit.getProgressionUnitBars()) { String chords = metaDataChordInfo.getPartChords(); if(chords == null || chords.equals("")){ metaDataChordInfo.setPartChords(pBar.getChord().getRawChordName()); }else{ metaDataChordInfo.setPartChords(metaDataChordInfo.getPartChords() + "-" + pBar.getChord().getRawChordName()); } } finishedTypes.add(pUnit.getType()); metaData.add(metaDataChordInfo); } return metaData; } @Autowired  SetMetaDataStateEvent(IMetaDataChordInfoDal metaDataChordInfoDal, IMetaDataTrackInfoDal metaDataTrackInfoDal, @Value("${api.version}") String api_version); }
SetMetaDataStateEvent implements IEventChain { public List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState){ List<ProgressionUnit.ProgressionType> finishedTypes = new ArrayList<>(); List<MetaDataChordInfo> metaData = new ArrayList<>(); for (ProgressionUnit pUnit : queueState.getStructure()) { if(finishedTypes.contains(pUnit.getType())){ continue; } MetaDataChordInfo metaDataChordInfo = new MetaDataChordInfo(); metaDataChordInfo.setTrackId(queueState.getQueueItem().getQueueItemId()); metaDataChordInfo.setPartType(pUnit.getType().toString()); metaDataChordInfo.setPartKey(pUnit.getKey()); metaDataChordInfo.setTrackKey("error"); for (ProgressionUnitBar pBar : pUnit.getProgressionUnitBars()) { String chords = metaDataChordInfo.getPartChords(); if(chords == null || chords.equals("")){ metaDataChordInfo.setPartChords(pBar.getChord().getRawChordName()); }else{ metaDataChordInfo.setPartChords(metaDataChordInfo.getPartChords() + "-" + pBar.getChord().getRawChordName()); } } finishedTypes.add(pUnit.getType()); metaData.add(metaDataChordInfo); } return metaData; } @Autowired  SetMetaDataStateEvent(IMetaDataChordInfoDal metaDataChordInfoDal, IMetaDataTrackInfoDal metaDataTrackInfoDal, @Value("${api.version}") String api_version); @Override QueueState set(QueueState queueState); List<MetaDataTrackInfo> getMetaDataTrackInfo(QueueState queueState); List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState); }
SetMetaDataStateEvent implements IEventChain { public List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState){ List<ProgressionUnit.ProgressionType> finishedTypes = new ArrayList<>(); List<MetaDataChordInfo> metaData = new ArrayList<>(); for (ProgressionUnit pUnit : queueState.getStructure()) { if(finishedTypes.contains(pUnit.getType())){ continue; } MetaDataChordInfo metaDataChordInfo = new MetaDataChordInfo(); metaDataChordInfo.setTrackId(queueState.getQueueItem().getQueueItemId()); metaDataChordInfo.setPartType(pUnit.getType().toString()); metaDataChordInfo.setPartKey(pUnit.getKey()); metaDataChordInfo.setTrackKey("error"); for (ProgressionUnitBar pBar : pUnit.getProgressionUnitBars()) { String chords = metaDataChordInfo.getPartChords(); if(chords == null || chords.equals("")){ metaDataChordInfo.setPartChords(pBar.getChord().getRawChordName()); }else{ metaDataChordInfo.setPartChords(metaDataChordInfo.getPartChords() + "-" + pBar.getChord().getRawChordName()); } } finishedTypes.add(pUnit.getType()); metaData.add(metaDataChordInfo); } return metaData; } @Autowired  SetMetaDataStateEvent(IMetaDataChordInfoDal metaDataChordInfoDal, IMetaDataTrackInfoDal metaDataTrackInfoDal, @Value("${api.version}") String api_version); @Override QueueState set(QueueState queueState); List<MetaDataTrackInfo> getMetaDataTrackInfo(QueueState queueState); List<MetaDataChordInfo> getMetaDataChordInfo(QueueState queueState);  }