Revision: 1773
Author: [email protected]
Date: Thu Dec 10 03:46:15 2009
Log: Initial import (does nothing useful yet)
http://code.google.com/p/simal/source/detail?r=1773
Added:
/trunk/uk.ac.osswatch.simal.ssmm/pom.xml
/trunk/uk.ac.osswatch.simal.ssmm/readme.txt
/trunk/uk.ac.osswatch.simal.ssmm/src
/trunk/uk.ac.osswatch.simal.ssmm/src/main
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal/ssmm
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal/ssmm/SustainabilityRating.java
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal/ssmm/model
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal/ssmm/model/Question.java
/trunk/uk.ac.osswatch.simal.ssmm/src/test
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac/osswatch
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac/osswatch/simal
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac/osswatch/simal/ssmm
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac/osswatch/simal/ssmm/model
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac/osswatch/simal/ssmm/model/QuestionTest.java
Modified:
/trunk/uk.ac.osswatch.simal.ssmm
=======================================
--- /dev/null
+++ /trunk/uk.ac.osswatch.simal.ssmm/pom.xml Thu Dec 10 03:46:15 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>uk.ac.osswatch</groupId>
+ <artifactId>simal-ssmm</artifactId>
+ <version>0.1-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src/main</sourceDirectory>
+ <testSourceDirectory>src/test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
=======================================
--- /dev/null
+++ /trunk/uk.ac.osswatch.simal.ssmm/readme.txt Thu Dec 10 03:46:15 2009
@@ -0,0 +1,13 @@
+This module provides a module for the measuring of the sustainability of
open source
+software by providing an evaluation mechanism.
+
+Use
+===
+
+To use the application from the command line run:
+
+java uk.ac.osswatch.simal.ssmm.SustainabilityRating
+
+The application will ask you a series of questions and, upon completion,
will provide a
+rating based on the Sustainability Maturity Model.
+
=======================================
--- /dev/null
+++
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal/ssmm/SustainabilityRating.java
Thu Dec 10 03:46:15 2009
@@ -0,0 +1,42 @@
+package uk.ac.osswatch.simal.ssmm;
+
+import java.util.Scanner;
+
+import uk.ac.osswatch.simal.ssmm.model.Question;
+
+public class SustainabilityRating {
+
+ private static final Object HELP_COMMAND = "help";
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ System.out.println("Please answer the following questions.");
+ System.out.println("If you want more details type '" +
HELP_COMMAND
+ "'");
+ System.out.println("If you are unsure of the answer simply
press
enter");
+
+ Question question = new Question("What is the project name?",
"Please
provide a project name.");
+ String answer = askQuestion(question);
+ System.out.println("Name: " + answer);
+ }
+
+ /**
+ * Ask a question and return the answer. The answer is also stored in
the
question
+ * object.
+ *
+ * @param question
+ * @return
+ */
+ private static String askQuestion(Question question) {
+ System.out.println(question.getText());
+ Scanner in = new Scanner(System.in);
+ String answer = in.nextLine();
+ if (answer.equals(HELP_COMMAND)) {
+ System.out.println(question.getDetails());
+ return askQuestion(question);
+ }
+ question.setAnswer(answer);
+ return question.getAnswer();
+ }
+}
=======================================
--- /dev/null
+++
/trunk/uk.ac.osswatch.simal.ssmm/src/main/uk/ac/osswatch/simal/ssmm/model/Question.java
Thu Dec 10 03:46:15 2009
@@ -0,0 +1,82 @@
+package uk.ac.osswatch.simal.ssmm.model;
+
+/**
+ * A base question type that allows a free text answer.
+ *
+ */
+public class Question {
+ String text;
+ String details;
+ String answer;
+
+ /**
+ * Create a default question that accepts a text response.
+ *
+ * @param text - the text of the question
+ * @param details - a description of the question
+ * @param answer - a default answer
+ */
+ public Question(String text, String details,
+ String answer) {
+ setText(text);
+ setDetails(details);
+ setAnswer(answer);
+ }
+
+ /**
+ * Create a default question that accepts a text response.
+ *
+ * @param text the text of the question
+ * @param details a description of the question
+ */
+ public Question(String text, String details) {
+ setText(text);
+ setDetails(details);
+ }
+
+ /**
+ * Get the text of the question.
+ * @return
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Set the text of the question.
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * Get the descriptive details of the question. This can, optionally,
contain HTML.
+ * @return
+ */
+ public String getDetails() {
+ return details;
+ }
+
+ /**
+ * Set the descriptive details of the question. This can, optionally,
contain HTML.
+ */
+ public void setDetails(String details) {
+ this.details = details;
+ }
+
+ /**
+ * Get the answer (if any) provided for this question.
+ * @return
+ */
+ public String getAnswer() {
+ return answer;
+ }
+
+ /**
+ * Set the answer (if any) provided for this question.
+ */
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/uk.ac.osswatch.simal.ssmm/src/test/uk/ac/osswatch/simal/ssmm/model/QuestionTest.java
Thu Dec 10 03:46:15 2009
@@ -0,0 +1,67 @@
+package uk.ac.osswatch.simal.ssmm.model;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test base functions of the Question class.
+ *
+ */
+public class QuestionTest {
+
+ static String QUESTION_TEXT = "Is this a question?";
+ static String QUESTION_DETAILS = "This is just a question for testing.";
+ static String QUESTION_ANSWER = "Yes, of course it's a question.";
+
+ static Question question;
+
+ @BeforeClass
+ public static void createQuestion() {
+ question = new Question(QUESTION_TEXT, QUESTION_DETAILS,
QUESTION_ANSWER);
+ }
+
+ @Test
+ public void testCreateQuestion(){
+ Question test = new Question(QUESTION_TEXT, QUESTION_DETAILS);
+ assertEquals("Question text is incorrect", QUESTION_TEXT,
test.getText());
+ assertEquals("Description for question is not being set
correctly",
QUESTION_DETAILS, test.getDetails());
+ }
+
+ @Test
+ public void testGetText() {
+ assertEquals("Question text is incorrect", QUESTION_TEXT,
question.getText());
+ }
+
+ @Test
+ public void testSetText() {
+ question.setText("testing");
+ assertEquals("Question text is not being set correctly",
"testing",
question.getText());
+ question.setText(QUESTION_TEXT);
+ }
+
+ @Test
+ public void testGetAnswer() {
+ assertEquals("Answer to question is incorrect",
QUESTION_ANSWER,
question.getAnswer());
+ }
+
+ @Test
+ public void testSetAnswer() {
+ question.setAnswer("testing");
+ assertEquals("Answer to question is not being set correctly",
"testing",
question.getAnswer());
+ question.setAnswer(QUESTION_ANSWER);
+ }
+
+ @Test
+ public void testGetDescription() {
+ assertEquals("Description for question is incorrect",
QUESTION_DETAILS,
question.getDetails());
+ }
+
+ @Test
+ public void testSetDescription() {
+ question.setDetails("testing");
+ assertEquals("Description for question is not being set
correctly", "testing", question.getDetails());
+ question.setDetails(QUESTION_DETAILS);
+ }
+}
--
You received this message because you are subscribed to the Google Groups
"Simal Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simal-commits?hl=en.