@Test public void testDoMatchDesired() throws Exception { GaugeDescription gdl = YamlUtil.loadGaugeSpecs(new File("src/test/resources/ServerEnablementGaugeTest/gauges.yml")); assertTrue(gdl.instDescList().size() == 1); GaugeInstanceDescription gd = gdl.instDescList().iterator().next(); Map<String, IRainbowOperation> mappings = new HashMap<> (); mappings.putAll(gd.mappings()); ServerEnablementGauge gauge = new ServerEnablementGauge(gd.gaugeName(), 10000, new TypedAttribute(gd.gaugeName(), gd.gaugeType()), gd.modelDesc(), gd.setupParams(), mappings); gauge.configureGauge(gd.configParams()); gauge.initialize(mock(IRainbowReportingPort.class)); StandaloneResource resource = StandaloneResourceProvider.instance ().acmeResourceForString ( "src/test/resources/acme/znn.acme"); IAcmeSystem sys = resource.getModel ().getSystems ().iterator ().next (); assertTrue (sys.getDeclaredTypes ().iterator ().next ().isSatisfied ()); AcmeModelInstance mi = new BareAcmeModelInstance (sys); Whitebox.setInternalState(gauge, "m_model", mi); String testInput = "o 127.0.0.1:8080"; IProbeIdentifier testProbe = MockingUtil.mockProbeIdentifier("test", "test", "JAVA"); gauge.start(); gauge.reportFromProbe(testProbe, testInput); gauge.reportFromProbe(testProbe, testInput); gauge.reportFromProbe(testProbe, testInput); gauge.reportFromProbe(testProbe, testInput); }
private AcmeModelInstance getModel () { if (m_model == null) { m_model = (AcmeModelInstance) m_modelsPort.<IAcmeSystem>getModelInstance (new ModelReference (m_modelDesc .getName (), m_modelDesc.getType ())); } return m_model; }
ServerEnablementGauge extends RegularPatternGauge { private AcmeModelInstance getModel () { if (m_model == null) { m_model = (AcmeModelInstance) m_modelsPort.<IAcmeSystem>getModelInstance (new ModelReference (m_modelDesc .getName (), m_modelDesc.getType ())); } return m_model; } }
ServerEnablementGauge extends RegularPatternGauge { private AcmeModelInstance getModel () { if (m_model == null) { m_model = (AcmeModelInstance) m_modelsPort.<IAcmeSystem>getModelInstance (new ModelReference (m_modelDesc .getName (), m_modelDesc.getType ())); } return m_model; } ServerEnablementGauge(String id, long beaconPeriod, TypedAttribute gaugeDesc, TypedAttribute modelDesc,
                                  List<TypedAttributeWithValue> setupParams, Map<String, IRainbowOperation> mappings); }
ServerEnablementGauge extends RegularPatternGauge { private AcmeModelInstance getModel () { if (m_model == null) { m_model = (AcmeModelInstance) m_modelsPort.<IAcmeSystem>getModelInstance (new ModelReference (m_modelDesc .getName (), m_modelDesc.getType ())); } return m_model; } ServerEnablementGauge(String id, long beaconPeriod, TypedAttribute gaugeDesc, TypedAttribute modelDesc,
                                  List<TypedAttributeWithValue> setupParams, Map<String, IRainbowOperation> mappings);  }
ServerEnablementGauge extends RegularPatternGauge { private AcmeModelInstance getModel () { if (m_model == null) { m_model = (AcmeModelInstance) m_modelsPort.<IAcmeSystem>getModelInstance (new ModelReference (m_modelDesc .getName (), m_modelDesc.getType ())); } return m_model; } ServerEnablementGauge(String id, long beaconPeriod, TypedAttribute gaugeDesc, TypedAttribute modelDesc,
                                  List<TypedAttributeWithValue> setupParams, Map<String, IRainbowOperation> mappings);  static final String NAME; static final String DEFAULT; static final Pattern PATTERN; }