@Test public void ShouldSetPhase_C1_L3_C3_L1_C2_L4_C4_L2() { QueueState queueState = new QueueState(); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C1_L3)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState.setDataSource(createSourceData()); queueState.setQueueItem(getQueueItem(new ArrayList<ProgressionUnit.ProgressionType>() {{ add(ProgressionUnit.ProgressionType.VERSE); add(ProgressionUnit.ProgressionType.CHORUS); add(ProgressionUnit.ProgressionType.BRIDGE); }})); queueState = chordStructureGenerator.set(queueState); queueState.getStructure().forEach(pUnit -> { HiveChord chordOne = pUnit.getProgressionUnitBars().get(0).getChord(); Boolean chordIsMatch = chordOne.isEqual("amin7"); assertThat(chordIsMatch).isTrue(); }); queueState = harmonicLoopGenerator.setHarmonicLoops(queueState, Composition.Layer.HARMONIC_LOOP); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState.getStructure().forEach(pUnit -> { HarmonicLoop currentLoop = pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop(); boolean isEqual = "loopOneBar".equalsIgnoreCase(currentLoop.getFileName()) || "loopTwoBar".equalsIgnoreCase(currentLoop.getFileName()); assertThat(isEqual).isTrue(); }); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C3_L1)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState = chordStructureGenerator.set(queueState); queueState.getStructure().forEach(pUnit -> { HiveChord chord = pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); Boolean chordIsMatch = chord.isEqual("amin7") || chord.isEqual("amin"); assertThat(chordIsMatch).isTrue(); }); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C3_L1)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState = harmonicLoopGenerator.setHarmonicLoops(queueState, Composition.Layer.HARMONIC_LOOP); String bb = ""; queueState.getStructure().forEach(pUnit -> { HarmonicLoop currentLoop = pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).getHarmonicLoop(); boolean isEqual = false; if(!isEqual){ isEqual = "loopOneBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 1; } if(!isEqual){ isEqual = "loopTwoBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 1; } if(!isEqual){ isEqual = "loopFourBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 1; } assertThat(isEqual).isTrue(); }); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C2_L4)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState = chordStructureGenerator.set(queueState); queueState.getStructure().forEach(pUnit -> { HiveChord chord = pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_TWO).getChord(); Boolean chordIsMatch = chord.isEqual("amin7") || chord.isEqual("amin"); assertThat(chordIsMatch).isTrue(); }); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C2_L4)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState = harmonicLoopGenerator.setHarmonicLoops(queueState, Composition.Layer.HARMONIC_LOOP); queueState.getStructure().forEach(pUnit -> { HarmonicLoop currentLoop = pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop(); boolean isEqual = false; if(!isEqual){ isEqual = "loopOneBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 4; } if(!isEqual){ isEqual = "loopTwoBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 4; } if(!isEqual){ isEqual = "loopFourBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 4; } assertThat(isEqual).isTrue(); }); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C4_L2)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState = chordStructureGenerator.set(queueState); queueState.getStructure().forEach(pUnit -> { HiveChord currentChord = pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).getChord(); HiveChord expectedChord = new HiveChord("amin7"); assertThat(currentChord.hasMatchingRoot(expectedChord)).isTrue(); }); queueState.setProcessingState(new ProcessingState(ProcessingState.ProcessingStates.C4_L2)); queueState.getProcessingState().setProcessingPattern(ProcessingPattern.TWO_BAR); queueState = harmonicLoopGenerator.setHarmonicLoops(queueState, Composition.Layer.HARMONIC_LOOP); queueState.getStructure().forEach(pUnit -> { HarmonicLoop currentLoop = pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).getHarmonicLoop(); boolean isEqual = false; if(!isEqual){ isEqual = "loopOneBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 2; } if(!isEqual){ isEqual = "loopTwoBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 2; } if(!isEqual){ isEqual = "loopFourBar".equalsIgnoreCase(currentLoop.getFileName()) && currentLoop.getCurrentBar() == 2; } if(!isEqual){ String debugy = ""; } assertThat(isEqual).isTrue(); }); }
public QueueState set(QueueState queueState) { Application.logger.debug("LOG: $$$ THREAD ID chord generate : " + Thread.currentThread().getId()); List<ProgressionType> progressionTypes = getProgressionTypes(queueState.getQueueItem()); LogProcedureState(queueState.getProcessingState().getCurrentState(), HarmonicStructureGenerator); switch (queueState.getProcessingState().getProcessingPattern()){ case TWO_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L3: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C3_L1: queueState.setProceed(setChordThree(queueState.getStructure(), queueState.getDataSource().getHiveChordInDatabase())); break; case C2_L4: queueState.setProceed(setChordTwo(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; case C4_L2: queueState.setProceed(setChordFour(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; } break; case FOUR_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L1: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C2_C3_C4: HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap = chordSelector.selectChordsFrom4BarLoop(queueState.getStructure()); set2nd3rd4thChordsFor4BarLoops(queueState.getStructure(), progressionTypeListHashMap); default: break; } break; default: break; } return queueState; }
ChordStructureGenerator implements IChordStructureGenerator { public QueueState set(QueueState queueState) { Application.logger.debug("LOG: $$$ THREAD ID chord generate : " + Thread.currentThread().getId()); List<ProgressionType> progressionTypes = getProgressionTypes(queueState.getQueueItem()); LogProcedureState(queueState.getProcessingState().getCurrentState(), HarmonicStructureGenerator); switch (queueState.getProcessingState().getProcessingPattern()){ case TWO_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L3: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C3_L1: queueState.setProceed(setChordThree(queueState.getStructure(), queueState.getDataSource().getHiveChordInDatabase())); break; case C2_L4: queueState.setProceed(setChordTwo(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; case C4_L2: queueState.setProceed(setChordFour(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; } break; case FOUR_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L1: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C2_C3_C4: HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap = chordSelector.selectChordsFrom4BarLoop(queueState.getStructure()); set2nd3rd4thChordsFor4BarLoops(queueState.getStructure(), progressionTypeListHashMap); default: break; } break; default: break; } return queueState; } }
ChordStructureGenerator implements IChordStructureGenerator { public QueueState set(QueueState queueState) { Application.logger.debug("LOG: $$$ THREAD ID chord generate : " + Thread.currentThread().getId()); List<ProgressionType> progressionTypes = getProgressionTypes(queueState.getQueueItem()); LogProcedureState(queueState.getProcessingState().getCurrentState(), HarmonicStructureGenerator); switch (queueState.getProcessingState().getProcessingPattern()){ case TWO_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L3: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C3_L1: queueState.setProceed(setChordThree(queueState.getStructure(), queueState.getDataSource().getHiveChordInDatabase())); break; case C2_L4: queueState.setProceed(setChordTwo(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; case C4_L2: queueState.setProceed(setChordFour(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; } break; case FOUR_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L1: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C2_C3_C4: HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap = chordSelector.selectChordsFrom4BarLoop(queueState.getStructure()); set2nd3rd4thChordsFor4BarLoops(queueState.getStructure(), progressionTypeListHashMap); default: break; } break; default: break; } return queueState; }  }
ChordStructureGenerator implements IChordStructureGenerator { public QueueState set(QueueState queueState) { Application.logger.debug("LOG: $$$ THREAD ID chord generate : " + Thread.currentThread().getId()); List<ProgressionType> progressionTypes = getProgressionTypes(queueState.getQueueItem()); LogProcedureState(queueState.getProcessingState().getCurrentState(), HarmonicStructureGenerator); switch (queueState.getProcessingState().getProcessingPattern()){ case TWO_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L3: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C3_L1: queueState.setProceed(setChordThree(queueState.getStructure(), queueState.getDataSource().getHiveChordInDatabase())); break; case C2_L4: queueState.setProceed(setChordTwo(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; case C4_L2: queueState.setProceed(setChordFour(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; } break; case FOUR_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L1: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C2_C3_C4: HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap = chordSelector.selectChordsFrom4BarLoop(queueState.getStructure()); set2nd3rd4thChordsFor4BarLoops(queueState.getStructure(), progressionTypeListHashMap); default: break; } break; default: break; } return queueState; }  List<ProgressionType> getProgressionTypes(QueueItem queueItem); QueueState set(QueueState queueState); boolean setChordThree(List<ProgressionUnit> progressionUnits, List<HiveChord> hiveChordInDatabase); boolean setChordTwo(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean set2nd3rd4thChordsFor4BarLoops(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap); boolean setFirstChordInProgressions(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, HiveChord> typeAndFirstChord); }
ChordStructureGenerator implements IChordStructureGenerator { public QueueState set(QueueState queueState) { Application.logger.debug("LOG: $$$ THREAD ID chord generate : " + Thread.currentThread().getId()); List<ProgressionType> progressionTypes = getProgressionTypes(queueState.getQueueItem()); LogProcedureState(queueState.getProcessingState().getCurrentState(), HarmonicStructureGenerator); switch (queueState.getProcessingState().getProcessingPattern()){ case TWO_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L3: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C3_L1: queueState.setProceed(setChordThree(queueState.getStructure(), queueState.getDataSource().getHiveChordInDatabase())); break; case C2_L4: queueState.setProceed(setChordTwo(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; case C4_L2: queueState.setProceed(setChordFour(queueState.getDataSource().getHiveChordInDatabase(), queueState.getStructure())); break; } break; case FOUR_BAR: switch (queueState.getProcessingState().getCurrentState()) { case C1_L1: HashMap<ProgressionType, HiveChord> typeAndFirstChord = chordSelector.selectFirstChordForType(progressionTypes, queueState.getDataSource().getHiveChordInDatabase()); queueState.setProceed(setFirstChordInProgressions(queueState.getStructure(), typeAndFirstChord)); break; case C2_C3_C4: HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap = chordSelector.selectChordsFrom4BarLoop(queueState.getStructure()); set2nd3rd4thChordsFor4BarLoops(queueState.getStructure(), progressionTypeListHashMap); default: break; } break; default: break; } return queueState; }  List<ProgressionType> getProgressionTypes(QueueItem queueItem); QueueState set(QueueState queueState); boolean setChordThree(List<ProgressionUnit> progressionUnits, List<HiveChord> hiveChordInDatabase); boolean setChordTwo(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean set2nd3rd4thChordsFor4BarLoops(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap); boolean setFirstChordInProgressions(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, HiveChord> typeAndFirstChord);  }