Package net.raymanoz.migrate

Examples of net.raymanoz.migrate.Script


     
      @Override
      public void doMigration() {
        for(int idx = 0; idx < noScriptsToMigrate(); idx++){
          final int scriptIdx = idx + 1;
          Script script = new Script() {
           
            @Override
            public Set<String> variablesRequiringDialog() {
              return null;
            }
View Full Code Here


    when(afterFinish.getPatchNo()).thenReturn(patch);
  }
 
 
  private Script mockScript(long dbVersion, long patch, ScriptStatus returnedScriptStatus){
    Script result = mock(Script.class);
    when(result.execute(any(UserInteractionStrategy.class))).thenReturn(returnedScriptStatus);
    when(result.getDBVersion()).thenReturn(dbVersion);
    when(result.getPatch()).thenReturn(patch);
    return result;
  }
View Full Code Here

    return mockScript(dbVersion, patch, null)
  }
 
  @Test
  public void alreadyMigrated(){
    final Script script_1_1 = mockScript(1, 1);
    final Script script_1_10 = mockScript(1, 10);
    final Script script_2_1 = mockScript(2, 1);
    final Script script_3_10 = mockScript(3, 10);

    setVersion(1, 0);
    assertFalse(command.alreadyMigrated(script_1_1));
    assertFalse(command.alreadyMigrated(script_1_10));
    assertFalse(command.alreadyMigrated(script_2_1));
View Full Code Here

  }

 
  @Test
  public void migrateSkipsIfScriptAlreadyMigrated() {
    final Script script = mockScript(1, 1);
    setVersion(1, 1);
    assertTrue(command.migrate(script));
    verify(repository).getVersion();
    verify(script).getDBVersion();
    verify(script).getPatch();
View Full Code Here

  }
 
  private void checkMigrate(ScriptStatus returnedScriptStatus, int scriptIdx, boolean expected){
    final long dbVersion = 23;
    final long patch = 2098;
    final Script script = mockScript(dbVersion, patch, returnedScriptStatus);
    setVersion(dbVersion, patch - 1);
    assertEquals(expected, command.migrate(script));

    verify(script, times(2)).getDBVersion();
    verify(script, times(2)).getPatch();
View Full Code Here

  private List<Script> mockScripts(long dbVersion, boolean includeRequiresDialog, ScriptStatus ... scriptStatus){
    List<Script> list = new ArrayList<Script>();
    int patch = 0;
    for(ScriptStatus status: scriptStatus){
      patch++;
      Script script = mockScript(dbVersion, patch, status);
      if (includeRequiresDialog) {
        when(script.variablesRequiringDialog()).thenReturn(forRequiresDialog(dbVersion, patch));
      }
      list.add(script);
    }
    return list;
  }
View Full Code Here

    verifyNoMoreInteractions(repository, userInteractionStrategy, version);
  }
 
  @Test
  public void addPropertiesNeedingValuesAlreadyMigrated(){
    final Script script = mockScript(1, 1);
    @SuppressWarnings("unchecked")
    final Set<String> variables = mock(Set.class);
    setVersion(1, 1);
    command.addPropertiesNeedingValues(script, variables);
    verify(script).getDBVersion();
View Full Code Here

  }
 
  @Test
  @SuppressWarnings("unchecked")
  public void addPropertiesNeedingValues(){
    final Script script = mockScript(2, 1);
    final Set<String> variables = mock(Set.class);
    final Set<String> returned = mock(Set.class);
    when(script.variablesRequiringDialog()).thenReturn(returned);
    setVersion(1, 1);
    command.addPropertiesNeedingValues(script, variables);
    verify(script).getDBVersion();
    verify(script).getPatch();
    verify(script).variablesRequiringDialog();
View Full Code Here

    List<Script> scripts = new ArrayList<Script>();
    long scriptNo = 0L;
    ScriptList result = mock(ScriptList.class);
    for (String scriptName: scriptNames){
      scriptNo++;
      Script script = mock(Script.class);
      when(script.getDBVersion()).thenReturn(dbVersion);
      when(script.getFileName()).thenReturn(scriptName);
      when(script.getPatch()).thenReturn(scriptNo);
     
      when(script.condtionStatus()).thenReturn("Test");
      when(script.execute(any(UserInteractionStrategy.class))).thenThrow(new RuntimeException("TBI"));
      when(script.compareTo(any(Script.class))).thenThrow(new RuntimeException("TBI"));
      scripts.add(script);
      when(result.get((int)scriptNo)).thenReturn(script);
    }
    when(result.iterator()).thenReturn(scripts.iterator());
    when(result.size()).thenReturn(scripts.size());
View Full Code Here

TOP

Related Classes of net.raymanoz.migrate.Script

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.