Skip to content

Code Documentation

NilsKasper edited this page Jun 13, 2024 · 42 revisions

MWApiWrapper Documentation

Class Methods

baseEndpoint

Returns the base URL for the OpenMensa API.

mealsPostfix

Returns the postfix URL for fetching meals, with placeholders for canteen ID and date.

getMealsFrom:on:

Fetches the meals from openmensa.org for a specified canteen on a specified date. Both parameters should be strings, and the date needs to be formatted as 'YYYY-MM-DD'. The return type is a JSON string.

Tests

testApiCallWithInvalidUrl

Tests the API call with an invalid URL. Asserts that the response is empty or an network error occurred.

testApiCallWithValidUrl

Tests the API call with a valid URL. Asserts that the response from 'MWApiWrapper' matches the expected content from the unwrapped call or an network error occurred.

MWParser Documentation

Class Methods

put:in:

Translates the Dataset into a Json or multiple Jsons and reads the information provided into the instance of a given class. The function returns a list of instances of the provided class, as many as there are valid Json objects in the Dataset.

set:on:from:

Sets a desired instance variable on any class instance from a dataset. If no data is provided for the given instance variable, nil ist the default value.

Tests

testMWParserSetOnFromInvalidData

It tests that the MWParser puts nil in the instance variable fields that no data is provided for.

testMWParserSetOnFromValidData

It tests that the MWParser puts the correct values into the instance variables if data is provided.

testMWParserSetOnFromValidExtensiveData

It tests that the MWParser ignores any additional properties in datasets.

testMWParserWithMultipleJSONObjects

It tests that the MWParser correctly returns two class instances with the correct instance variables for multiple provided JSON objects.

testMWParserWithOneJSONObject

It tests that the MWParser correctly returns a class instance with the values provided by the data put into the instance variables.

MWDataGettingWrapper Documentation

Class Methods

canteenDict

Returns a dictionary with canteen id strings as keys and corresponding canteen name strings as values.

getTodaysMeals

Returns a Collection of CanteenObjects that are filled in with id, name, date and meals using the date of today and all in the dict, that is stored classside, canteenids. It works by unsing the MWParser and MWApiWrapper look there for more documentation.

getMealsOn:

Returns a Collection of CanteenObjects that are filled in with id, name, date and meals using the date that is given to the function in the dict, that is stored classside, canteenids. It works by unsing the MWParser and MWApiWrapper look there for more documentation.

Tests

testSize

It test that the Collection returned by todaysMeals is equal to the size of the keys in the dict stored classside.

testCollectionClasses

It test that all objects in the Collection returned by todaysMeals are of the MWCanteen class.

testCollectionValues

It test that all objects in the Collection returned by todaysMeals have data filled in an no field is nil.

MWFrame Documentation

Instance Methods

openMensaWidget

This is a method that allows on instance creation assembling all the neccesary parts.

createFrame

It assembles all parts of the frame itself providing position, extend and other important information.

addText

This adds a TextMorph displaying the text Lunchtime as a placeholder for the actual meal information and adds it as PaneMorph.

Tests

testContent

Tests that the Frame has Panemorphs, to make sure it has some sort of content.

testCorrectSubclass

Tests that the Frame as a class is the subclass of a PluggableSystemWindow as it sould be.

testCorrectTitle

Tests that the Frame has the right title, being "Mensa Widget".

testOpened

Tests the Frame one two things. First it test that is has been opened in the world and therefore visible. Secondly it test that it is opened and not collapsed on the side.

testSize

Tests that the Frame is not bigger initialy than the world it is in.

MWMeals Documentation

Instance variables

category

The category is a String correlating to the meal category provided by the endpoint.

id

The ID is a number correlating to the ID provided by the endpoint.

name

The name is a String correlating to the provided name by the endpoint.

notes

The notes are an ordered collection of additional info provided by the endpoint.

prices

The prices are a JSON object storing the prices for students, employees, pupils and others provided by the endpoint.

MWCanteens Documentation

Instance Variables

id

The canteen id as a string correlation to the id at the endpoint.

name

The canteen name in german.

date

The date where the following meals for this canteen are available as a string in the format yyyy-mm-dd.

meals

A OrderedCollection of meals that are available aat the specified day at this canteen.

MWColorTheme Documentation

Class Methodes

primaryColor

Returns a Color that is meant to be the primary color of the widget.

secondaryColor

Returns a Color that is meant to be the secondary color of the widget.

backgroundColor

Returns a Color that is meant to be the background color of the widget.

transparentColor

Returns a Color that is meant to be the transparent color of the widget.

MWMenuBar Documentation

Instance Methodes

decreaseDate:

Given a Event stamming from a button click the date will be updated and the menus newly rendered for the previous day. Also the button will give visual feedback by changing color for that duration.

increaseDate:

Given a Event stamming from a button click the date will be updated and the menus newly rendered for the following day. Also the button will give visual feedback by changing color for that duration.

updateDate

The date display that is showing the user its date will update to the date stored in the instance variable and also the target being the window the MenuBar belongs to will display the meals for the day being shown.