@Test public void testUpdateContext_queryIndexes() { this.context.instancePathToComponentName.put( "/tomcat-vm/oops 1", this.app.getTomcatVm().getComponent().getName()); this.context.instancePathToComponentName.put( "/tomcat-vm/oops 2", this.app.getTomcatVm().getComponent().getName()); this.context.instancePathToComponentName.put( "/tomcat-vm/oops 3", this.app.getTomcatVm().getComponent().getName()); String instr14 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MIN ) under /tomcat-vm"; AbstractCommandInstruction instr = new DefineVariableCommandInstruction( this.context, instr14, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 1", this.context.variables.get( "exi" )); String instr15 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MIN > 1 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr15, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 2", this.context.variables.get( "exi" )); String instr16 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MIN > 2 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr16, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 3", this.context.variables.get( "exi" )); String instr17 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MIN > 3 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr17, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertTrue( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "fake", this.context.variables.get( "exi" )); String instr18 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MAX ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr18, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 3", this.context.variables.get( "exi" )); String instr19 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MAX > 1 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr19, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 3", this.context.variables.get( "exi" )); String instr20 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MAX < 3 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr20, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 2", this.context.variables.get( "exi" )); String instr21 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MAX < 2 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr21, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertFalse( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "oops 1", this.context.variables.get( "exi" )); String instr22 = "define exi = oops " + EXISTING_INDEX_PREFIX + " MAX > 3 ) under /tomcat-vm"; instr = new DefineVariableCommandInstruction( this.context, instr22, 1 ); Assert.assertEquals( 0, instr.validate().size()); instr.updateContext(); Assert.assertTrue( instr.isDisabled()); Assert.assertNotNull( this.context.variables.get( "exi" )); Assert.assertEquals( "fake", this.context.variables.get( "exi" )); Assert.assertEquals( 1, this.context.disabledVariables.size()); Assert.assertEquals( "exi", this.context.disabledVariables.iterator().next()); }
@Override public void updateContext() { String newValue = replaceVariables( this.value, this.context, this.instancePath ); if( newValue != null ) { this.context.variables.put( this.key, newValue ); } else { setDisabled( true ); this.context.disabledVariables.add( this.key ); this.context.variables.put( this.key, "fake" ); String path = "/fake"; if( this.instancePath != null ) path = this.instancePath + path; this.context.instancePathToComponentName.put( path, FAKE_COMPONENT_NAME ); } }
DefineVariableCommandInstruction extends AbstractCommandInstruction { @Override public void updateContext() { String newValue = replaceVariables( this.value, this.context, this.instancePath ); if( newValue != null ) { this.context.variables.put( this.key, newValue ); } else { setDisabled( true ); this.context.disabledVariables.add( this.key ); this.context.variables.put( this.key, "fake" ); String path = "/fake"; if( this.instancePath != null ) path = this.instancePath + path; this.context.instancePathToComponentName.put( path, FAKE_COMPONENT_NAME ); } } }
DefineVariableCommandInstruction extends AbstractCommandInstruction { @Override public void updateContext() { String newValue = replaceVariables( this.value, this.context, this.instancePath ); if( newValue != null ) { this.context.variables.put( this.key, newValue ); } else { setDisabled( true ); this.context.disabledVariables.add( this.key ); this.context.variables.put( this.key, "fake" ); String path = "/fake"; if( this.instancePath != null ) path = this.instancePath + path; this.context.instancePathToComponentName.put( path, FAKE_COMPONENT_NAME ); } } DefineVariableCommandInstruction( Context context, String instruction, int line ); }
DefineVariableCommandInstruction extends AbstractCommandInstruction { @Override public void updateContext() { String newValue = replaceVariables( this.value, this.context, this.instancePath ); if( newValue != null ) { this.context.variables.put( this.key, newValue ); } else { setDisabled( true ); this.context.disabledVariables.add( this.key ); this.context.variables.put( this.key, "fake" ); String path = "/fake"; if( this.instancePath != null ) path = this.instancePath + path; this.context.instancePathToComponentName.put( path, FAKE_COMPONENT_NAME ); } } DefineVariableCommandInstruction( Context context, String instruction, int line ); @Override List<ParsingError> doValidate(); @Override void updateContext(); }
DefineVariableCommandInstruction extends AbstractCommandInstruction { @Override public void updateContext() { String newValue = replaceVariables( this.value, this.context, this.instancePath ); if( newValue != null ) { this.context.variables.put( this.key, newValue ); } else { setDisabled( true ); this.context.disabledVariables.add( this.key ); this.context.variables.put( this.key, "fake" ); String path = "/fake"; if( this.instancePath != null ) path = this.instancePath + path; this.context.instancePathToComponentName.put( path, FAKE_COMPONENT_NAME ); } } DefineVariableCommandInstruction( Context context, String instruction, int line ); @Override List<ParsingError> doValidate(); @Override void updateContext(); static final String MILLI_TIME; static final String NANO_TIME; static final String FORMATTED_TIME_PREFIX; static final String EXISTING_INDEX_PREFIX; static final String RANDOM_UUID; static final String SMART_INDEX; }