Assignment 2 – A couple of simple components
1 The back-end service
2 The front-end service

Assignment 2 – A couple of simple components

Due Wednesday 4/7 5:00pm for the testing deliverables and Friday 4/9 11:59pm for the code deliverables

1 The back-end service

Implement a component that provides a single operation called sort that consumes a list of 10 special JSON objects and sorts them in ascending order based on the numerical value of their content member.

The grammar below describes the shapes of the JSON that your program must accept. There are two different categories of text in the following grammar. Text that is in a blue fixed-width font is literal text that must appear (using the whitespace rules given in the JSON specification). Text that is in boldface roman text is a non-terminal and refers to another part of the specification (so it is not literal but you must look at its definition to know what should appear). The vertical bars indicate alternatives, meaning that you should choose exactly one of those (any of them is fine) for each use of a non-terminal in bold. For example, where you see value you can replace it with a natural number between one and twenty four.

special-object

 ::= 

{ "content" : value }

value

 ::= 

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12

 | 

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24

Together with the sorting component, you should also implement a test driver, i.e., a program that simulates a sufficient part of the environment of a component so that we can unit test the component. In this particular case, your test driver should read 10 special JSON objects from STDIN, pass them to the back-end service, and display the result in STDOUT as a JSON array of 10 objects.

Testing Deliverables: In your team’s GitHub repository, create a directory "Deliverables/2/2.1/" and deposit there five input files for the test driver and their expected output files. Of course, to do testing correctly, you should create the output files before writing any code. Name the input files "input1.json", "input2.json", etc. and the corresponding output files "output1.json", "output2.json", etc.

You will receive up to five points for your tests, one point for each valid pair of input and output files.

Code Deliverables: In your team’s GitHub repository, in the same "Deliverables/2/2.1/" directory, add either a script named run that runs the test driver of your back-end service or a Makefile that produces an executable run for the test driver.

You will receive up to twenty-five points for your back-end service depending on how many tests its test driver passes.

2 The front-end service

Implement a component that reads JSON values from STDIN and, once STDIN is closed,
  • filters out all but the special-object JSON objects (from the grammar above);

  • splits those JSON values that remain after filtering in groups of 10 respecting the order they were provided through STDIN (leftover objects that do not make a full group are discarded);

  • uses the back-end component to sort each group and;

  • outputs each sorted groups to STDOUT as a single JSON array (that contains JSON arrays with 10 objects each). The result must respecting the order the groups were provided on STDIN.

Testing Deliverables: In your team’s GitHub repository, create a directory "Deliverables/2/2.2/" and deposit there at least five input files for the front-end service and their expected output files. Name the input files "input1.json", "input2.json", etc. and the corresponding output files "output1.json", "output2.json", etc.

You will receive up to five points for your tests, one point for each valid pair of input and output files.

Code Deliverables: In your team’s GitHub repository, in the directory "Deliverables/2/2.2/" add a Makefile that will install any needed dependencies and produces an executable run for your front-end service. (If your program can be run via a shell script, it is okay to just push the shell script, but you must have a Makefile, even if it does nothing.)

You will receive up to twenty-five points for your front-end service depending on how many tests it passes.