public static void main(String[] args) { System.out.println(Arrays.toString(args)); UmlWrapper umlWrapper = new UmlWrapper(); for (String arg : args) { umlWrapper.addClass(arg); } umlWrapper.addBuilderClass(ExtensionBuilder.class); umlWrapper.addBuilderClass(ImplementsBuilder.class); umlWrapper.addBuilderClass(AssociationBuilder.class); umlWrapper.addBuilderClass(DecoratorBuilder.class); umlWrapper.addBuilderClass(AdapterBuilder.class); umlWrapper.addBuilderClass(SingletonBuilder.class); umlWrapper.addBuilderClass(UsesBuilder.class); umlWrapper.addBuilderClass(CompositeBuilder.class); umlWrapper.addPhase(new Load(umlWrapper)); umlWrapper.addPhase(new PatternDetection(umlWrapper)); umlWrapper.addPhase(new GenerateUML(umlWrapper)); umlWrapper.addPhase(new Print(umlWrapper)); try { umlWrapper.execute(); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } }
public <T> ArrayList<T> convert(T obj) { ArrayList<T> ret = new ArrayList<T>(); for (HashMap<String, Object> record : this.data) { Constructor<T> c = null; try { c = (Constructor<T>) obj.getClass().getDeclaredConstructor(); } catch (NoSuchMethodException | SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { T toAdd = c.newInstance(); for (String key : record.keySet()) { try { Field f = toAdd.getClass().getDeclaredField(key); f.setAccessible(true); f.set(toAdd, record.get(key)); } catch (SecurityException | NoSuchFieldException e) { e.printStackTrace(); } } ret.add(toAdd); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } return ret; }
public static Frame getSharedOwnerFrame() { try { Method getSharedOwnerFrame = SwingUtilities.class.getDeclaredMethod("getSharedOwnerFrame"); // package-protected Object frame = SystemUtils.invoke( null, getSharedOwnerFrame); // getSharedOwnerFrame() is static - invoke it on null object return (frame instanceof Frame) ? (Frame) frame : null; } catch (NoSuchMethodException | SecurityException e) { e.printStackTrace(); } return null; }
/** * Set the AI for this entity. * * @param ai */ public final void setAI(Class<? extends EntityAI2D> ai) { try { EntityAI2D aiv = ai.getConstructor(Entity2D.class).newInstance(this); this.ai = aiv; this.health = aiv.getMaxHealth(); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { CrimsonLog.warning( "Unable to apply AI %s to entity %s because %s.", ai, this, e.getMessage()); CrimsonLog.severe(e); } }
private void invalidValueHelper(Object obj, String methodName, int i) { try { Method m = obj.getClass().getMethod(methodName, int.class); m.invoke(obj, i); fail("Didn't cause an invalid value exception."); } catch (NoSuchMethodException | SecurityException e) { System.err.println("Error when getting the method. Uh oh!"); e.printStackTrace(); fail(); } catch (IllegalAccessException | IllegalArgumentException e) { System.err.println("Error when invoking the method. Uh oh!"); e.printStackTrace(); fail(); } catch (InvocationTargetException e) { assertEquals(JsonTypeException.class, e.getTargetException().getClass()); } }
@Override public Object newInstance(Constructor<?> constructor, Object... initargs) throws InvocationTargetException, InstantiationException, IllegalAccessException { // TODO Auto-generated method stub Object object = null; if (Modifier.isAbstract(constructor.getDeclaringClass().getModifiers())) { Class<?> clazz; Constructor<?> newConstructor; String className = "de.signaliduna.testautomation.nlv.fixture.NlvFixtureElanImpl"; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { throw new StopTestException( "Die Klasse '" + className + "' kann nicht geladen werden. Nachricht" + e.getMessage(), e); } try { newConstructor = clazz.getConstructor(); } catch (NoSuchMethodException | SecurityException e) { throw new StopTestException( "Der Standardconstructor für die Klasse '" + className + "' kann nicht erzeugt werden. Nachricht" + e.getMessage(), e); } object = super.newInstance(newConstructor, initargs); } else { object = super.newInstance(constructor, initargs); } if (object instanceof StoppableFixture) { String name = object.getClass().getName(); if (!stoppableFixtures.containsKey(name)) { stoppableFixtures.put(name, new ArrayList<StoppableFixture>()); } stoppableFixtures.get(name).add((StoppableFixture) object); stoppableFixturesList.add((StoppableFixture) object); } return object; }
@SuppressWarnings("unchecked") public <E> E doSession( Object session, String sessionMethodName, Object[] parameterList, String expectedJSONObjectFileName, String expectedJSONArrayFileName, String expectedXMLFileName, ExpectedExceptionObject expectedException) throws TestException, IOException, JSONException { E actualResult = null; Class<?>[] parameterClassList = new Class<?>[parameterList.length]; for (int i = 0; i < parameterList.length; i++) { parameterClassList[i] = parameterList[i].getClass(); } Method method = null; try { method = session.getClass().getMethod(sessionMethodName, parameterClassList); } catch (NoSuchMethodException | SecurityException e) { e.printStackTrace(); throw new Error(e); } try { actualResult = (E) method.invoke(session, parameterList); System.out.println("--- Result ---"); System.out.println(JsonService.getJsonStringFromJavaObject(actualResult)); System.out.println("--------------"); if (null != expectedException) { throw new TestNoExceptionException(expectedException.getExpectedClass().toString()); } } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); throw new Error(e); } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); // There was an exception but was not defined the expected OR it was not the expected !!!! if (null == expectedException || !targetException.getClass().equals(expectedException.getExpectedClass())) { throw new TestNotExpectedExceptionException( expectedException.getClass().getSimpleName(), targetException.getClass().getSimpleName()); // The exception was the expected but probably the message was different } else { String expectedMessage = expectedException.getExactMessage(); // The exact message was specified but it not the same as the catched if (null != expectedMessage && !expectedMessage.equals(targetException.getMessage())) { throw new TestNotExpectedExceptionMessageException( expectedMessage, targetException.getLocalizedMessage()); } } } // -------------------- // Compare XML the DB // -------------------- if (null != expectedXMLFileName) { try { String difference = CompareXMLToDB.getDifference(expectedXMLFileName, conn, database); if (null != difference) { throw new TestCompareXMLToDBException(expectedXMLFileName, difference); } } catch (ParserConfigurationException | SAXException | IOException | SQLException e) { // e.printStackTrace(); throw new TestCompareXMLToDBFormatException(e.getLocalizedMessage()); } } // --------------------------------- // Compare JSONObject to the result // --------------------------------- if (null != expectedJSONObjectFileName) { CompareJSONToResult.doCompareAsJSONObject(expectedJSONObjectFileName, actualResult); // --------------------------------- // Compare JSONArray to the result // --------------------------------- } else if (null != expectedJSONArrayFileName) { CompareJSONToResult.doCompareAsJSONArray(expectedJSONArrayFileName, actualResult); } return actualResult; }
@Override public void run() { Converter cServer = (Converter) ModuleRegistry.get("Converter"); while (true) { if (queue.size() > 0) { ConvertFile cF = queue.get(0); try { FFmpeg ffmpeg = new FFmpeg("ffmpeg"); FFprobe ffprobe = new FFprobe("ffprobe"); FileData cFParent = cServer.getFileStorage().get(cF.getParentUUID()); FFmpegProbeResult result = ffprobe.probe(cFParent.getFileName()); try { Class<?> c = (new Presets(cF.getPreset())).get(); Constructor<?> p = c.getDeclaredConstructor( FFmpegProbeResult.class, String.class, String.class, String.class); Preset preset = (Preset) p.newInstance( new Object[] {result, cFParent.getFileName(), cF.getSource(), ""}); ProcessBuilder builder = new ProcessBuilder(preset.getCmd().split(" ")); if (builder != null) { builder.redirectErrorStream(true); pr = builder.start(); InputStream is = pr.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = ""; while ((line = br.readLine()) != null) { if (SynloadFramework.debug) { System.out.println(line); } } br.close(); isr.close(); is.close(); } FileData fdN = new FileData(cF.getVideoUUID(), preset.getOutputFile()); cServer.storeFile(cF.getVideoUUID(), fdN); InformationDocument iD = new InformationDocument("c_complete", cF.getVideoUUID()); iD.getObjects().put("size", (new File(preset.getOutputFile())).length()); iD.getObjects().put("runtime", result.getFormat().duration); iD.getObjects().put("type", preset.getName()); iD.getObjects().put("name", preset.getOutputFile()); iD.getObjects().put("parent", cFParent.getId()); for (Client client : ServerTalk.getConnected()) { client.write(iD); // broadcast finished video } queue.remove(0); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } try { Thread.sleep(1L); } catch (InterruptedException e) { e.printStackTrace(); } } }
private void defineTransformations() { MetaOverTwoRelation metaGroupDep = instOverTwoRelation.getMetaOverTwoRelation(); boolean targetActiveAttribute = false; if (instOverTwoRelation.getTargetRelations().size() > 0) // TODO support multiple targets targetActiveAttribute = (boolean) ((InstPairwiseRelation) instOverTwoRelation.getTargetRelations().get(0)) .getTargetRelations() .get(0) .getInstAttribute("Active") .getValue(); if (targetActiveAttribute && metaGroupDep != null) { relationType = (String) instOverTwoRelation .getInstAttribute(SemanticOverTwoRelation.VAR_RELATIONTYPE_IDEN) .getValue(); // System.out.println(relationType); for (String sourceName : instOverTwoRelation.getSourceAttributeNames()) { AbstractExpression abstractTransformation = null; Iterator<InstElement> instEdges1 = instOverTwoRelation.getSourceRelations().iterator(); AbstractExpression recursiveExpression1 = null; AbstractExpression recursiveExpression2 = null; if (instEdges1.hasNext()) { InstElement left1 = instEdges1.next(); while ((boolean) ((InstPairwiseRelation) left1) .getSourceRelations() .get(0) .getInstAttribute("Active") .getValue() == false) { if (instEdges1.hasNext()) left1 = instEdges1.next(); else return; } switch (relationType) { case "and": abstractTransformation = new AndBooleanExpression(); break; case "or": abstractTransformation = new OrBooleanExpression(); break; case "mutex": abstractTransformation = new SumNumericExpression(); break; case "range": abstractTransformation = new SumNumericExpression(); Iterator<InstElement> instEdges2 = instOverTwoRelation.getSourceRelations().iterator(); // instEdges2.next(); // TODO eliminate duplicated edges // from collection and remove this // line InstElement left2 = instEdges2.next(); Constructor<?> constructor3 = null, constructor4 = null; try { constructor3 = abstractTransformation .getClass() .getConstructor( InstElement.class, String.class, Boolean.TYPE, AbstractExpression.class); constructor4 = abstractTransformation .getClass() .getConstructor( InstElement.class, InstElement.class, String.class, String.class); } catch (NoSuchMethodException | SecurityException e) { e.printStackTrace(); } recursiveExpression2 = transformation(constructor3, constructor4, instEdges2, left2, sourceName); break; case "": return; default: return; } Constructor<?> constructor1 = null, constructor2 = null; try { constructor1 = abstractTransformation .getClass() .getConstructor( InstElement.class, String.class, Boolean.TYPE, AbstractExpression.class); constructor2 = abstractTransformation .getClass() .getConstructor( InstElement.class, InstElement.class, String.class, String.class); } catch (NoSuchMethodException | SecurityException e) { e.printStackTrace(); } switch (relationType) { case "and": // B_Satisfied #<=> ( ( A1_"attribute" #/\ // A2_"attribute" ) #/\ ... ) case "or": // B_Satisfied #<=> ( ( A1_"attribute" #\/ // A2_"attribute" ) #\/ ... ) recursiveExpression1 = transformation(constructor1, constructor2, instEdges1, left1, sourceName); getTransformations() .add( new DoubleImplicationBooleanExpression( instOverTwoRelation, sourceName, true, recursiveExpression1)); break; case "mutex": // B_Satisfied #<=> (( ( A1_"attribute" + A2_"attribute" // ) + ... ) #<=> 1) recursiveExpression1 = transformation(constructor1, constructor2, instEdges1, left1, sourceName); AbstractExpression transformation1 = new EqualsComparisonExpression( recursiveExpression1, new NumberNumericExpression(1)); getTransformations() .add( new DoubleImplicationBooleanExpression( instOverTwoRelation, sourceName, true, transformation1)); break; case "range": // B_"attribute" #<=> ( ( ( ( A1_"attribute" + // A2_"attribute" ) + ... ) #>= GD_LowCardinality) #/\ // ( ( ( A1_"attribute" + A2_"attribute" ) + ... ) #<= // GD_HighCardinality ) ) recursiveExpression1 = transformation(constructor1, constructor2, instEdges1, left1, sourceName); AbstractExpression transformation3 = new GreaterOrEqualsBooleanExpression( instOverTwoRelation, "lowCardinality", false, recursiveExpression1); AbstractExpression transformation4 = new LessOrEqualsBooleanExpression( instOverTwoRelation, "highCardinality", false, recursiveExpression2); AbstractExpression transformation5 = new AndBooleanExpression(transformation3, transformation4); getTransformations() .add( new DoubleImplicationBooleanExpression( instOverTwoRelation /* * .getTargetRelations * ().get(0) * .getToRelation() */, sourceName, true, transformation5)); break; default: return; } } } } }